All pastes #353067 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-13 04:38 UTC
rendered paste body
// Program about sum, product, division, and riminder.
 # include <iostream>
 using namespace std;
 int main()
 {
   int num1=0;  // integers number1.
   int num2=0;  // integers number2.
   float num3; // float number3.

   int sum1;  // sum of the number1 and number2.
   int prod1; // product of the number1 and number2.
   int quot1; // division of the number1 and number2.
   int rmd;   // riminder of the number1 and number2.
   float sum2; // sum of the number1 and number3.
   float prod2; // product of the number1 and number3
   float quot2; // division of the number1 and number3
   cout<< "enter the num1: ";
   cin >> num1;
   cout<< "enter the num2 (> 8): " ;
   cin >> num2 ;

   cout <<" num1" << '\t' << "num2" << '\t' << "num3" << '\t';
   cout << "sum1" << '\t' << "sum2" << '\t';
   cout << "prod1" << '\t' << "prod2" << '\t';
   cout << "quot1" << '\t' << "quot2" << '\t';
   cout << "rmd" << endl;
   cout << num1 << '\t' << num2 << '\t' << num3 << '\t';
   cout << sum1 << '\t' << quot2 << '\t' << rmd << endl;
  // THIS IS THE PART OF CALCULATION

 num3 = num2 * 1.0;
 sum1 = num1 + num2 ;
 sum2 = num1 + num3 ;
 prod1 = num1 * num2 ;
 prod2 = num1 * num3 ;
 quot1 = num1 / num2 ;
 quot2 = num1 / num3 ;
 rmd = num1 % num2 ;
 cout << num1 << '\t' << num2 << '\t' << num3 << '\t';
 cout << sum1 << '\t' << sum2 << '\t' << prod1 << '\t' << prod2 << '\t';
 cout << quot1 <<'\t' << quot2 <<'\t' << rmd << endl;
 num1=num1 + 5;
 num2=num2 - 3;
//PART OF CALCULATION ENDS HERE


//  What happen if you repeat the above part again ?  but this time see the num1 is not the one you entered, its //the value after the num1+5 is
//performed, so if you repeat this one more time like below what are the results //coming ?

// THIS IS THE PART OF CALCULATION

 num3 = num2 * 1.0;
 sum1 = num1 + num2 ;
 sum2 = num1 + num3 ;
 prod1 = num1 * num2 ;
 prod2 = num1 * num3 ;
  quot1 = num1 / num2 ;
 quot2 = num1 / num3 ;
 rmd = num1 % num2 ;
 cout << num1 << '\t' << num2 << '\t' << num3 << '\t';
 cout << sum1 << '\t' << sum2 << '\t';
 cout << prod1 << '\t' << prod2 << '\t';
 cout << quot1 << '\t' << quot2 << '\t';
 cout << rmd << endl;
 num1=num1 + 5;
 num1=num1 + 5;
 num2=num2 - 3;
 num2=num2 - 3;

// PART OF CALCULATION ENDS HERE



 return 0;
}