-1

On the last line in the code below, the compiler give me an error on the "\n":

ERROR expected ';' before string constant

#include <iostream>
using namespace std;

int main()
{
    int num1;
    double num2;
    cout << "enter the inetger: \n";
    cin>>num1;
    cout<<"enter the float: \n";
    cin>>num2;
    cout<<"integer:""\t"<<num1<<" and float:""\t"<<num2"\n";
    return 0;
}

Here is an Image:

image

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
inoobbe
  • 3
  • 2

1 Answers1

1

you have to use << to concatenate like

cout<<"integer:""\t"<<num1<<" and float:""\t"<<num2<<"\n";

or better use

cout<<"integer:""\t"<<num1<<" and float:""\t"<<num2<<endl;
Andrew Nic
  • 108
  • 1
  • 11