#include <iostream>
using namespace std;
int main ()
{
int Age =25;
string name = "John";
cout << Age name ;
return 0;
}
compilation
In function 'int main()':
10:13: error: expected ';' before 'name'
#include <iostream>
using namespace std;
int main ()
{
int Age =25;
string name = "John";
cout << Age name ;
return 0;
}
compilation
In function 'int main()':
10:13: error: expected ';' before 'name'
For C++, you need all the other important parts, such as the include files, and the namespace qualifiers.
Unlike most scripting languages, the programming statements and expressions have to be in the context of a function.
For example:
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main()
{
int Age = 25;
string name = "John";
cout << Age << " " << name << endl;
return 0;
}
The error says that there's a missing semicolon somewhere, your compiler should tell you in which line is the error and you might find it. Also you should do all the previous steps in the c++ code as following :
#include <iostream>
using namespace std;
int main()
{
int age = 25;
string name= "john";
cout<<"The age is: "<<age<<endl;
cout<<"The name is: "<<name<<endl;
return 0;
}
if there's still a problem please clarify it.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int Age ;
Age = 32;
string name ;
name = "ahmed";
cout << "age is"<< Age << " " <<endl;
cout<< "name is " << name << endl;
return 0;
try this
#include <iostream>
using namespace std;
int main(){
int Age =25; string name = "John";
cout<< name << " age ="<<Age;}
you mean that