Revision 1
Revision 1
1. Write a C function that accepts a string as a parameter and finds the maximum
number present in the string.
Sample:
Input: “10 15 2 35 98 12”
Output: The maximum number is: 98
2. Write a C function that accepts a string as a parameter and finds the even number
present in the string.
Sample:
input: “7 10 35”
Output: The even number is: 10
3. Write a C function that accepts a string as a parameter and Calculate the Sum of all
NUMBERS present in the string.
Sample:
input: “5 sd10 ds15abc”
Output: The Sum of all number is: 30
4. Write a C function that accepts a string as a parameter, find and Calculate the Sum of
all NUMBERS present in the string. (Note: very different from exercise 3)
Sample:
input: “5 sd10 ds15abc”
Output: Numbers in the string are: 5, 10, 15. The Sum is: 30
5. Write a C function that accepts a string as a parameter and calculate the Sum of all
DIGITS (0,1,2…,8,9) present in the string.
Sample:
input: “5 s15b”
Output: The Sum of all digit is: 11
6. Write a C function that accepts an input from users. If the input is the number with
value of q or Q, then prompt to the screen that: “The input is Q, quitting now…” then quit
the program
7. Write a C function to count the number of vowels anf consonants in a given string. The
function accept a string as parameter and return the count of vowels and consonants
8. Write a C function that accepts a character array as a parameter and reverses it. After
that, print the reversed arry.
Example:
Input: “abc def”
Output: “fed cba”
9. Write a C function that accepts a string as a parameter and Calculate the average of
all DIGITS presented in the string.
Example
Input: “10 20 25” Output: 1.66
10. Write a C function that accepts a string as a parameter and Calculate the average of
all number presented in the string.
Example
Input: “10 20 25” Output: 18.33
11. Write a C function that accepts an input from users. If the input is NOT the number
then promtp: “The input is not number” and quit the program. (Note Can use #include
<ctype> , and use isdigit() function)
12. Write 2 functions in C that accept an array as a parameter. The function will return
sum of even/odd number
13. Write a program to calculate the sum as the expression with the given value n:
14. Write a funtion that accept an integer array as a parameter. Print all number that
are even/odd.
15. Write a funtion that accept an integer array as a parameter and return the
average of all the numbers in that array.