Finding errors – Programming basics – Computer Sir Ki Class
  

Login
[lwa]



Solved Problem! #CPP#3159 siteicon   siteicon   siteicon  

Problem Statement - Finding errors – Programming basics

Find the errors in the following code and explain.

TC++ #3159

#include <iostream>
using namespace std;
float main()
{
cout<< "Sun rises">>" in the east.";
return 0;
}

Test it !

Solution


#include <iostream> //OK
using namespace std; //OK
float main()                 //NOT-OK, main must return int type. in old compilers void is also allowed
{
cout<< “Sun rises”>>” in the east.”;
NOT-OK, >> operator can not be used in cout chain. We can only use stream insertion operator << while writing the cout chain.
return 0;  //OK
}


Share

sunmitra| Created: 29-Jan-2018 | Updated: 30-Jan-2018|






Back