Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes

 
Evil Grin C programming Count uppercase letters in a sentence
Reply
Posted 2004-10-15, 10:35 PM
I don't know where to start or how to write the program I need some help I am trying to program an uppercase character is an character whose ASCII value is between 65(A) and 90(Z). I need to write a program that prompts the user to enter a string from the keyboard and will count the number uppercase character and replace each uppercase character by the corresponding lowercase character.
Old
Profile PM WWW Search
deadlock75 is neither ape nor machine; has so far settled for the in-betweendeadlock75 is neither ape nor machine; has so far settled for the in-between
 
deadlock75
 



 
Reply
Posted 2004-10-16, 06:41 AM in reply to deadlock75's post "C programming Count uppercase letters..."
deadlock75 said:
I don't know where to start or how to write the program I need some help I am trying to program an uppercase character is an character whose ASCII value is between 65(A) and 90(Z). I need to write a program that prompts the user to enter a string from the keyboard and will count the number uppercase character and replace each uppercase character by the corresponding lowercase character.
PHP Code:
#include <stdio.h>

int main(void)
{
     
char string[50];
     
gets(string);
     
int count 0;
     
int i;
     for(
0string[i]; i++)
     {
          if(
string[i] >= 'A' && string[i] <= 'Z')     
          {
               
count++;
          }
     }

     
printf("%d"count);


Last edited by Demosthenes; 2004-10-16 at 01:05 PM.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 



 
Reply
Posted 2004-10-16, 12:55 PM in reply to Demosthenes's post starting "#include <stdio.h> int main(void) {..."
Actually, it would be
for(i=0;i<strlen(string);i++)
not
for(i=0;i<string[i];i++)
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2004-10-16, 12:56 PM in reply to WetWired's post starting "Actually, it would be..."
WetWired said:
Actually, it would be
for(i=0;i<strlen(string);i++)
not
for(i=0;i<string[i];i++)
Actually, I don't even know why I did
Code:
i<string[i]
I meant to just say
Code:
string[i]
I'll go ahead and change that.

But yea, WW's method is better. Use strlen.

Last edited by Demosthenes; 2004-10-16 at 01:12 PM.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 02:17 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.