Trouble with the A+B problem
Posted by
Maxim 13 Sep 2011 23:58
Hi, i'm trying to solve the A+B problem, and it works on my computer. But the compiler of this site doesn't accept my solution. It says "Compilation error" :
"11e2cd04-2636-421c-9639-3a45ac221379
11e2cd04-2636-421c-9639-3a45ac221379(4) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
here is my program:
#include <iostream>
using namespace std;
main () {
long a,b;
cin >> a;
cin >> b;
cout << a+b;
};
Where did I do mistakes?
Thank you for attention.
Re: Trouble with the A+B problem
Posted by
Kleninz 17 Sep 2011 09:20
try this:
#include <iostream>
using namespace std;
int main () {
long a,b;
cin >> a;
cin >> b;
cout << a+b;
}
Re: Trouble with the A+B problem
Posted by
Maxim 17 Sep 2011 21:27
But, it's the same. (:
Re: Trouble with the A+B problem
Posted by
divya 23 Sep 2011 22:42
I think the difference is in return type of main.
Kindly correct if i am wrong.
Re: Trouble with the A+B problem
Posted by
divya 23 Sep 2011 22:43
I think the difference is in return type of main.
Kindly correct if i am wrong.
Re: Trouble with the A+B problem
Posted by
Maxim 24 Sep 2011 03:21
Thank you so much! Finally it worked!
Re: Trouble with the A+B problem
#include<stdio.h>
void main()
{
float a,b,s=0.0;
scanf("%f%f",&a,&b);
s=a+b;
printf("sum=%f",s) ;
}
i don't know where is problem in this programme
Edited by author 27.09.2011 20:50
Re: Trouble with the A+B problem
use int, lol
Edited by author 15.10.2011 15:51
Re: Trouble with the A+B problem
no "return"
Re: Trouble with the A+B problem
Posted by
ReadMe 23 Oct 2011 00:06
This is an example problem. You should read an FAQ to get start.
Re: Trouble with the A+B problem
Posted by
Th3_g0d 25 Oct 2011 19:58
First of all you haven't shown the type of main function :)
Re: Trouble with the A+B problem
output must be as this :
cout <<(a+b);
or:
cout <<'a+b';
sorry for my English)