BCS-1A

Thursday, December 29, 2011

More than 2 Numbers Add


/*******************************************************
*  Name: Add more than 2 numbers                       *
*                                                      *
*  Copyright: BCS-1A                                   *
*                                                      *
*  Author: Muhammad Hussnain Imtiaz                    *
*                                                      *
*  Date: 21/12/11 23:07                                *
*                                                      *
*  Description: Program to add more than 2 numbers     *
*******************************************************/

// preprocessor directive
#include<iostream>
#include<conio.h>
using namespace std ;
int main ()
{
    // Local declaration
    int marks =0 ,
        i        ,
        sum   =0 ,
        code  =0 ,
        ;
    double n      =0.0 ,
           average=0.0 ,
           ;
    cout << "          How much numbers you want to enter numbers: " ;
    cin  >> n ;
    cout << endl << endl ;
    for (i=1 ; i<=n ; i++)   // 1st for loop start
    {
    cout << "                     Enter Number " << i << ":" ;
    cin  >> marks ;
    }
        sum = sum+marks ;
    cout << "\n             System add them and their addition is " << sum  ;
        average = sum/n ;
    cout << "\n                    Their Average is " << average ;
    getch();
for (i=1; code != 12345; i++)  // 2nd for loop, just for lock
{
    system ("CLS");
    cout << "\n                  Press exit code :";
    cin  >> code ;
    if (code == 12345)
{  
     system ("CLS");
     cout << "\n\n\n\n\n\n\n\n\n\n\n     "
          << "              Created By:Mohammad Hussnain Imtiaz   " ;
} // End of if
    else
{
     cout << "          you enter invalid code, press 'Enter' to retry." ;
     getch();
}
}// end of for
   
getch () ;  
return 0 ;
} // end of main function

No comments:

Post a Comment