|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I want to help a friend of mine who just started learning programming in C, but has problems catching up because he doesn't have any previous knowledge of it. I myself know vb.NET but never programmed in C, so I can't help.
![]() Some things that are asked: - A program which counts vowels in a given text using switch.case. (Similar to VB's "select case"? How to write this?) - A program that calculates powers (ex. 3^4 when 3 and 4 are given by the user) without using pow(a,b). I was thinking of writing something like A*((B-1)* "*A"), which would probably work in VB but how do you write this correctly in C? - A program in which the user enters an amount of numbers, then it returns the minimum, maximum and average value when -1 is entered. I asked another friend of me about this and he wrote down the following code, but we were unable to test it. Would it work? #include <stdio.h> int main(void) { int min = 0; int max = 0; int sum = 0; int count_numbers = 0; int read_number = -1; scanf(“%d”, &read_number); int min = read_number; int max = read_number; int sum = read_number while (read_number != -1){ if(read_number < min) min = read_number; else if(read_number> max) max = read_number; sum+= read_number; count_numbers++; scan f(“%d”, &read_number); } printf(“min %d”, min); printf(“max %d”, max); printf(“average %d”, sum/count_numbers); } scanf If there is anyone who would be willing to help in any way, by writing down the code (and if possible a little bit of explanation) I would be really grateful. Thanks a lot in advance! |
| Sponsored Links |
|
|
|
|||
|
The power is easy using recursion
C Code:
This only works for an integer index greater than or equal to 0. As for switch statements. They can be done as follows C Code:
The breaks ensure that only one case is executed. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic | u2cannv | General Programming | 8 | 10-05-2007 10:24 PM |
| A few basic website questions | ehudgershon | General Programming | 4 | 06-11-2007 03:20 PM |
| HTML Basic Formatting | clookid | Tutorials | 14 | 03-06-2007 04:10 PM |
| My friend made some cool BASIC videos | elfshadow14 | The Lounge | 5 | 01-09-2007 11:20 PM |
| Parallel Port Programming Using Visual Basic | kevintcp85 | Visual Basic Programming | 12 | 12-06-2006 01:09 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |