Why do I get a Compilation error?

i have tested this code on my computer while using Turbo c++ . but this is not compiling in c++ 4.0.0-8.

#include<iostream.h>
#include<conio.h>
void main()
{
int x;
float y;
cin>>x;
cin>>y;
if(x%5==0){
y=(y-x)-0.50;
}
cout<<y;
getch();
}

1)"<conio.h>" header is not supported by the gcc compiler that code chef uses. remove that header .

2)also you need to make void main() to int main() and add a “return 0” at the end.

3)Also remove the getch() at the end.

do these things and and it should work fine.

2 Likes

May be this can help

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x;
float y;
cin>>x;
cin>>y;
if(x%5==0){
y=(y-x)-0.50;
}
cout<<y;
cin.get();//you can add this as well
return 0;
}

always avoid using clrscr(),getch() etc,and shift to any gcc compiler to reduce such problems

use gcc compiler

//