Confused: New line for text

I am writing my first program and so I choose to make a calculator like program. But I don't know how to make text go on a seperate line.

This is what I have so far:

#include <iostream>

using namespace std;

int main()
{
float thisisanumber;
float multi;
int type;

cout<<"Please enter a mathematical process:";

cout<<" 1 for addition!";

cout<<" 2 for multiplication!";

cout<<" 3 for division!";
cin>> type;
cin.ignore();

cout<<"Please enter a number: ";
cin>> thisisanumber;
cin.ignore();
cout<<"Please enter a second number: ";
cin>> multi;
cin.ignore();

if (type == 1) {
cout<<"The addition is: "<< thisisanumber+multi;
cin.get();
}
else if (type == 2) {
cout<<"The multiplication is: "<< thisisanumber*multi;
cin.get();
}
else {
cout<<"The division is: " << thisisanumber/multi;
cin.get();
}


}
Last edited on
You can use \n after or before the text in quote. ex. cout << " 1 for addition!\n"; or cout << "\n 1 for addition!";. Or use cout << endl << " 1 for addition!"; or cout << " 1 for addition!" << endl;.
Thank you so much. I know it sound like a stupid question but I got really confused.
You're very welcome. And there is no reason to apologize, for we all get a bit confused in programming, one time or another. I'm just glad that we both weren't confused at the same time... ;)
For a better understanding of why you need a newline character, do a little research on output streams. Or the ostream library of C++. I find it always helps to know WHY you have to do something, not just that you have to do it.

Biscuit
Topic archived. No new replies allowed.