CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2010
    Posts
    5

    Thumbs down please please please Need help urgently

    This is the code of my assignment programme problem is this it takes the inputs properly but close the cmd window without showing any result. Where i m making any mistake please mention?and correct the code please. please please please

    Code:
    #include <iostream.h>
    using namespace std;
    main()
    {                                     //Initialization of veriables
          char grad;                     //to take inputs of grades A or B
          int tnos, ga, gb;              
          tnos = 1;                      //Total number of students
          ga = 0;                        //Total number of grad 'a'
          gb = 0;                        //Total number of grad 'b'
          do
          {
               cout<<"Enter the Grade of Student "<<tnos<<" :";    //to take inputs
                     cin>>grad;
                     if(grad=='a')            //to decide while the grade is 'a', 'b' or anyother
                     {
                             ga=ga+1;            //counter to count 'a' grades
                             tnos=tnos+1;
                             }
                     else if(grad=='b')
                     {
                                  gb=gb+1;          //counter to count 'b' grades
                                  tnos=tnos+1;
                                  }
                     else
                     {
                         cout<<"Please enter only grads A or B:";
                         }
                         }
                         while(tnos<=10);               //maximum inputs to take or total number of students whos grades are required
                                    {
                                         cout<<"Total A grades are : "<<ga;
                                         cout<<"Total B grades are : "<<gb;
                                         }
                                         
                                         //Now on the basis of total number of grades we shell show the status of a class.
                                         
                                         if(ga<=2)
                                         cout<<"Your class is Poor..!";
                                         else if(ga<=7)
                                         cout<<"Your class is Good..!";
                                         else
                                         cout<<"Your class is Brilliant..!";
                     }

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: please please please Need help urgently

    Quote Originally Posted by sonog4 View Post
    This is the code of my assignment programme problem is this it takes the inputs properly but close the cmd window without showing any result.
    Run the program from the command-line.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    Re: please please please Need help urgently

    using namespace std;//before main

    system("pause");//before return whatever

    return whatever;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured