-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
  • 505,946
  • 29
  • 409
  • 696
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
  • 98
  • 1
  • 10