All pastes #353108 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-13 05:10 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'<< "sum1" << '\t' << "sum2" << '\t'; << "prod1" << '\t' << "prod2" << '\t' << "quot1" << '\t' << "quot2" << '\t'<< "rmd" << endl;

  // THIS IS THE PART OF CALCULATION

 num3= num2 * 1.0;        // Assume at this point num1 = 6 and num2 = 12
 sum1= num1 + num2 ;      // here sum1 = 18
 sum2= num1 + num3 ;       // here sum2 = 18.0
 prod1= num1 * num2 ;      // here prod1 = 72
 prod2= num1 * num3 ;      // here prod1 = 72.0
 quot1= num1 / num2 ;       // here quot1 = 0
 quot2= num1 / num3 ;       // here quot2 = 0.5
 rmd= num1 % num2 ;             // rmd = 6


 // below the above value should be displayed
 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;      // here num1, which was 6 before changed to 11
 num2=num2 - 3;      // and num2, which was 12 before is changed to 9

//PART OF CALCULATION ENDS HERE

// THIS IS THE PART OF CALCULATION

 num3 = num2 * 1.0;   // here num2 = 9, and num1 = 11  and num3 = 9.0
 sum1 = num1 + num2 ;  // here sum1 = 20
 sum2= num1 + num3 ;       // here sum2 = 20.0
 prod1= num1 * num2 ;      // here prod1 = 99
 prod2= num1 * num3 ;      // here prod1 = 99.0
 quot1= num1 / num2 ;       // here quot1 = 1
 quot2= num1 / num3 ;       // here quot2 = 1.22
 rmd= num1 % num2 ;             // rmd = 2

 // below the above value should be displayed
 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;      // here num1, which was 11 before changed to 16
 num2=num2 - 3;      // and num2, which was 9 before is changed to 6

// PART OF CALCULATION ENDS HERE


// NOW repeat the above code accordingly,


 return 0;
}