0
Requesting User To Input "Sum of two numbers"
#include <iostream> using namespace std; int main() { int a, b; int sum; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; sum = a + b; cout << "Sum is: " << sum <<endl; return 0; } My question is why /n can not be replaced at <<endl Any help please. <<ednl and /n are same.
3 Antworten
0
thanks
+ 10
You can write like this:
cout << "Sum is: " << sum << "\n";
+ 1
\n is used (as you did) in a string expression. like shamima did in his/her example too, within quotes. endl; is used out of string expressions (without quotes).