Click here to Skip to main content
11,577,240 members (63,094 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
how can i do a programme on lowercase to uppercase conversion using while loop, getchar() and putchar() ???

Posted by OP:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>

#define EOL '\n'
main()
{
    char letter[80];
    int tag , count=0;
    letter[count]=getchar();
    while(letter[count]!= EOL)
    {
    
        count=count+1;
        letter[count]=getchar();
        
    }
    tag=count;
    count=0;
    while(count)
}
Posted 19-Feb-13 7:36am
Edited 19-Feb-13 9:01am
v2
Comments
richcb at 19-Feb-13 13:47pm
   
Research the subject, write some code, compile, run and there you go. Jokes aside though, that is not how it works here at Code Project. You will have to attempt your project and then if you get stuck you can ask a specific question and provide the code associated with it.
wikiabhishek at 19-Feb-13 13:53pm
   
#include
#include
#include
#define EOL '\n'
main()
{
char letter[80];
int tag , count=0;
letter[count]=getchar();
while(letter[count]!= EOL)
{

count=count+1;
letter[count]=getchar();

}
tag=count;
count=0;
while(count
ryanb31 at 19-Feb-13 13:53pm
   
Do you know how to use a while loop, getchar() and putchar()? What do you have so far?
wikiabhishek at 19-Feb-13 13:53pm
   
i got this solution bt actually i can't understand the logic of the first loop???? will u plzz xplain me???

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

"i got this solution bt actually i can't understand the logic of the first loop???? will u plzz xplain me???"
#define EOL '\n'
main()
   {
   char letter[80];
   int tag , count=0;
   letter[count]=getchar();
   while(letter[count]!= EOL)
      {
      count=count+1;
      letter[count]=getchar();
      }
   tag=count;
   count=0;
   while(count

I don't know where you got it from - it's clear you didn't write it - but the loop is pretty simple.
It looks at each letter in the string in turn, until it comes to an end of line character (defined as a newline). First time in, it looks to see if the user started with a newline. Each time round the loop, it inserts a character from the user into the string. It then looks at it to see if the character it just inserted was the end of line character.

If you aren't sure what something does, draw it out on paper with a pencil: make an array a series of boxes, and manually work out what each instruction does, and copy it on the paper - with something this simple it is probably easier for you to see what is going on that way, than to look at memory with the debugger.
  Permalink  
Comments
wikiabhishek at 19-Feb-13 14:51pm
   
i have done it...nw will u plzz hlp me to solve this prgrmme using for loop????
OriginalGriff at 19-Feb-13 15:05pm
   
Sorry? You've done what? I am not sure what you are asking for...
wikiabhishek at 19-Feb-13 15:18pm
   
m asking for the solution of my question that i previously asked "a simple programme on lowercase to uppercase conversion using while loop, getchar() and putchar()" , but this time using for loop.....hope u undrstnd!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 155
1 Afzaal Ahmad Zeeshan 125
2 OriginalGriff 115
3 Richard MacCutchan 100
4 Abhinav S 90
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 676
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100