Question #200999

Identify the error/s in the following code below:

I) Main{ }

(

Cout<<"Name"

Cin>>name

)






Expert's answer

//The code is missing the header file iostream that enables us to work with cout and cin.
#include <iostream>
//we also need to use this namespace as it contains objects from the standard library
using namespace std;


int main() //The main function has to be declared as int, with () and not {}.
//"Main" should be in lowercase


{ //The body of the function should start with { and not );


char name[10]; //This variable was not declared and so could not be used


cout<<"Name"; //There was a missing semicolon and Cout should be in lowercase


cin>>name; //Missing semicolon and Cin should be in lowercase


return 0;//The return value of the function was missing


}//The body of the main function should be closed with } and not )
LATEST TUTORIALS
APPROVED BY CLIENTS