How to resolve the segmentation fault runtime error?
I am getting it again and again despite making changes to my code.
This in reference to the last question of the practice problems.
link:easy Problem - CodeChef
My code is as follows:
int main()
{
int i=0;
int a[10];
i have one more doubt that when i am writing the code in c++
i am getting the compile error for
1)cin was not declared in this scope
2)cout was not declared in this scope
code is:
int main()
{
int a,i;
for(i=0;;i++)
{
cin>>a;
if (a==42)
break;
else
cout<<a<<"\n";
}
return 0;
}
oh…i had used <iostream.h> instead of <iostream that’s why it wasn’t working…!!
but i want to ask why does the code run in C wihtout including header files?