Question

write C program that contains a function that gets a string as a parameter and returns...

write C program that contains a function that gets a string as a parameter and returns an integer value represents the number of uppercase letters in this string
example : "AbcDeFgh" output:"3"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

#include<stdio.h>

int main() {
int upper = 0;
char ch[80];
int i;

printf("\nEnter The String : ");
gets(ch);

i = 0;
while (ch[i] != '') {
if (ch[i] >= 'A' && ch[i] <= 'Z')
upper++;
i++;
}

printf("\nUppercase Letters : %d", upper);

return (0);
}

Explanation:

if(ch[i]>='A' && ch[i]< ='Z')

  • We can compare two Characters.
  • Generally Comparing Characters means Comparing Corresponding ASCII Values.

Output:

Enter The String Pritesh A Taral Uppercase Letters3

Thanks....

Add a comment
Know the answer?
Add Answer to:
write C program that contains a function that gets a string as a parameter and returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT