Thread: need help for assignment

  1. #1
    Registered User
    Join Date
    Oct 2018
    Posts
    8

    need help for assignment

    my code is like this. can you tell me about my mistakes
    Code:
    #include<stdio.h>int main()
    {
    int count=0;
    char ch;
    while(ch!=EOF)
    {
    ch=getchar();
    ch=(ch>='a'&& ch<='z')?(ch-'a'+'A'):ch;
    putchar(ch);
    if(ch)
    count++;
    }
    printf("%d",count);
    
    
    return 0;
    
    }
    Attached Images Attached Images need help for assignment-screenshot-2018-10-22-18-39-02-jpg 

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Why is the letter "A" not reported as a letter? I am talking about the directions not about your code.
    Edit2: I just figured out consonants are only what is supposed to be printed

    Tim S.
    Last edited by stahta01; 10-22-2018 at 01:06 PM. Reason: spelling
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Step 1: Write an program that outputs just the numbers of letters.
    After getting that to work; store the consonants into an array and output that.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Instead of:

    [...]
    Quote Originally Posted by kyper78 View Post
    Code:
    ch=(ch>='a'&& ch<='z')?(ch-'a'+'A'):ch;
    [...]

    You better use functions like isalpha , toupper , ... , in <ctype.h> header.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with C assignment
    By Lictor in forum C Programming
    Replies: 2
    Last Post: 01-20-2015, 12:25 PM
  2. Help!! Assignment!
    By Joeshua Lee in forum C++ Programming
    Replies: 2
    Last Post: 08-09-2011, 09:30 AM
  3. Help!! Assignment!
    By Joeshua Lee in forum C Programming
    Replies: 3
    Last Post: 08-09-2011, 09:30 AM
  4. New assignment.
    By Titanguy in forum C++ Programming
    Replies: 22
    Last Post: 10-20-2009, 11:55 AM
  5. Replies: 3
    Last Post: 04-26-2009, 08:54 AM

Tags for this Thread