CODES FOR C++ DOCUMENTS , BASED ON OXFORD TEXT BOOK, IX CLASS
1) TO FIND SIMPLE INTEREST USING PRINCIPAL, TIME PERIOD AND RATE
#include <iostream.h>
Int main()
{
float P, R, T, SI;
cout << " Enter the Principal amount = ";
cin >> P;
cout << " Enter the Time Period = ";
cin >> T;
cout << " Enter the rate of interest = ";
cin >> R;
SI = P * R * T/100;
cout << " The simple interest is = " << SI << "\n"
return 0;
}
2) TO FIND SUM, PRODUCT, AVERAGE
#include <iostream.h>
Int main()
{
Int n1, n2, n3, sum, product;
float average;
cout << " Enter the three numbers = ";
cin >> n1 >> n2 >> n3;
sum = n1 + n2 + n3
product = n1 * n2 * n3
average = float(sum) / 3;
cout << " The sum of the three numbers = " << sum << "\n";
cout << " The product of the three numbers = " << product << "\n";
cout << " The average of the three numbers = " << average << "\n";
return 0;
}
No comments:
Post a Comment