Dev c++ Return value problem

I am using win 7 so i have installed dev c++ software for c programming. Its working fine But output window get closed when i am returning any value.. guys help me out..

if i use getch(); it works but its not working when i am trying to return any value

Replies

  • simplycoder
    simplycoder
    @Pushkar: dont use getch(), getch() is not included in standard c++ library.
    Instead maintain structure like this.
    #include
    #include
    int  main(int argc,char* argv[])
     {
     //....codehere.....
     system("PAUSE");
     return 0;
     }
    
    
    
  • *pushkar*
    *pushkar*
    #include
    #include
    main()
    {
    float area;
    int radius=1;
    area=circle(radius);
    printf("%f",area);
    }
    circle(int r)
    {
    float a;
    a=3.14*r*r;
    system("PAUSE");
    return(a);

    }
    i wrote this program, the output window was appeared but when i pressed any key to continue, the output window get disappeared 😔
  • rahul69
    rahul69
    Well Pushkar in my opinion you need to put system("PAUSE") just before the closing braces of main function .Try this code:

    #include
    #include 
    circle(int r);
    main()
    {
    float area;
    int radius=1;
    area=circle(radius);
    printf("%f\n",area);
    system("PAUSE");
    return 0;
    }
    circle(int r)
    {
    float a;
    a=3.14*r*r;
    
    return(a);
    
    } 
    
    
  • *pushkar*
    *pushkar*
    Thanks rahul.. it works

You are reading an archived discussion.

Related Posts

Hello friends, Presently many of MNC and Indian companies are visiting several Colleges and institutes for campus placement. For the preparation of it, you have to learn and solve the...
Chetan Bhagat is back with a new book and it's titled Revolution 2020 - Love. Education. Ambition. This time, it's a story of three friends (two guys and a girl)...
HBR Blog Network - Harvard Business Review
i see that the facebook page dosent work on the home page why is that?
When i run the recorded script I got java.net.socketException:Connection Reset atsun .reflect.NativeConstrutorAccessorimpl.newlninstance0(native Method)...........How can i solve this problem.cNa any one here suggest me here .My mob number is 7428753075.