about this programme

This is a discussion on about this programme within the C Programming forums, part of the General Programming Boards category; Code: void main(){ char c; printf("Enter charactor"); scanf("%c",&c); if(c=='a') printf("Yes"); printf("Nope"); } i try above code using Turbo C but ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    about this programme

    Code:
    void main(){
    
    char c;
    
    printf("Enter charactor");
    scanf("%c",&c);
    if(c=='a')
    printf("Yes");
    
    printf("Nope");
    
    }
    i try above code using Turbo C but it didnt give expected output

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    Code:
    #include <stdio.h>  // This needs to be here for printf()/scanf()
    
    int main(){  // main() should always return an int
    
    char c;
    
    printf("Enter charactor");
    scanf("%c",&c);
    if(c=='a')
    printf("Yes");
    else  // Without this here, it would print Nope even if the letter was an 'a'
    printf("Nope");
    return 0;  // Again, main() needs to return an int
    }
    One more thing: Turbo C sucks. Download a free C compiler from this century. Something like Dev-C++, Pelles C, or Microsoft Visual Studio Express.

    And in the future, please say what output you actually expected instead of just saying that you didn't get the expected output.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help me with ma c programme..
    By eddie19 in forum C Programming
    Replies: 19
    Last Post: 08-12-2009, 07:53 AM
  2. Closing a programme with cin.get
    By Dontgiveup in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2009, 02:35 PM
  3. How to view the programme before it disappears
    By yousuf in forum C Programming
    Replies: 2
    Last Post: 03-22-2008, 08:12 AM
  4. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  5. Gui Programme does'nt Compiles from DOS
    By Shadowhunt in forum C++ Programming
    Replies: 1
    Last Post: 06-06-2003, 08:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21