Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   New to c++ language. Need help. (http://www.go4expert.com/forums/cpp-language-help-t20917/)

Vanna Guo 9Feb2010 06:31

New to c++ language. Need help.
 
I know this is a ridiculous question but I've only just started to learn c++ a few days ago, I'm trying to figure out how to add 12 and 33 together. So I want the sum to display 45.

this is what I have so far:

#include <iostream>
using namespace std;
int main ( ) {

int
a = 12;
b = 33;
char sum;
sum = a + b;

cout << "The sum of 12 and 33 is " << sum;
cout << "\n";

return 0;
}

please help me and my stupidity, and thank you very much!

shabbir 9Feb2010 07:29

Re: New to c++ language. Need help.
 
Why on earth you are trying to add two numbers into a character?

xpi0t0s 9Feb2010 12:52

Re: New to c++ language. Need help.
 
Code:

int a=12;
int b=33;
int sum;
sum=a+b;
cout << a << "+" << b << "=" << sum << endl;



All times are GMT +5.5. The time now is 13:36.