CrazyEngineers
  • 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
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • simplycoder

    MemberAug 25, 2011

    @Pushkar: dont use getch(), getch() is not included in standard c++ library.
    Instead maintain structure like this.
    #include<iostream>
    #include<cstdlib>
    int  main(int argc,char* argv[])
     {
     //....codehere.....
     system("PAUSE");
     return 0;
     }
    
    
    
    Are you sure? This action cannot be undone.
    Cancel
  • *pushkar*

    MemberAug 25, 2011

    #include<stdio.h>
    #include <stdlib.h>
    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 😔
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberAug 25, 2011

    Well Pushkar in my opinion you need to put system("PAUSE") just before the closing braces of main function .Try this code:

    #include<stdio.h>
    #include <stdlib.h>
    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);
    
    } 
    
    
    Are you sure? This action cannot be undone.
    Cancel
  • *pushkar*

    MemberAug 25, 2011

    Thanks rahul.. it works
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register