Though this site aims at understanding C language, I am writing a program for you in C++, to have a general idea about C++ too. A program in C++,to calculate the average of two numbers, which are entered by the keyboard while the execution of the program. Try to understand the program; #include < iostream > using namespace std; int main() { float num1,num2,average,sum; cout << "Enter the first number:"; cin >> num1; cout << "Enter the second number:"; cin >> num2; sum=num1+num2; average=sum/2; cout << "The sum of the two numbers is:"<< sum<<"\n"<<"The average of the two numbers is:" << average; return(0); } Explaination: The new file header used here in this C++ program is the #include . By this , we are asking the preprocessor to add the contents of the iostream file to our program. The program is written in the
Comments