0

What is wrong with my program?

#include <iostream> #include <cmath> using namespace std; int x; int y; int z; int main() { cin >> x; cin >> y; x+y >> z; cout << z; return 0; }

23rd Sep 2016, 11:29 AM
Misha Vinokurov
Misha Vinokurov - avatar
12 Respuestas
+ 7
z=x+y and x+y=z have different meaning in c++?
24th Sep 2016, 8:31 AM
Devendra Sanghavi
Devendra Sanghavi - avatar
+ 6
x+y >>z ? do you want assign x+y to z? right way to do it is: z = x +y;
23rd Sep 2016, 11:56 AM
Zaman
Zaman - avatar
+ 2
cin >> x; cin >> y; x+y >> z; //wrong!!! z=x+y ; cout << z; a point about >> look this code..... #include<iostream> using namespace std; int main(){ int a = 10; int b = (a>>1); // you can also use (a/2) cout<<b; return 0; }
26th Sep 2016, 9:59 PM
Navid Tak
Navid Tak - avatar
+ 1
if you want to store them in double or float variables, there is no need to do something extra: int a =5; double b= a; also if you want only to use an integer as double, just use it. compiler will consider it as double; or you can easily change any integer to double by multiply it by 1.0
23rd Sep 2016, 12:21 PM
Zaman
Zaman - avatar
+ 1
Try z=x+y
24th Sep 2016, 12:33 AM
Nathan
Nathan - avatar
0
gave an error.
23rd Sep 2016, 11:51 AM
Misha Vinokurov
Misha Vinokurov - avatar
0
put int values INSIDE main ()
23rd Sep 2016, 11:53 AM
Shrinivas Deshpande
Shrinivas Deshpande - avatar
0
What I have to do, if I want to change integer numbers to double float-pointed numbers?
23rd Sep 2016, 12:02 PM
Misha Vinokurov
Misha Vinokurov - avatar
0
x+y>>z should be z=x+y;
26th Sep 2016, 4:13 PM
Supriya P
- 2
put x+y =z; it will work
23rd Sep 2016, 11:45 AM
Shrinivas Deshpande
Shrinivas Deshpande - avatar
- 2
declate x,y,x inside the curly brackets, after the "int main()" declaration
23rd Sep 2016, 11:53 AM
Varmeet Singh
Varmeet Singh - avatar
- 5
#include <iostream> #include <cmath> using namespace std; int main() { int x; int y; int z; cin >> x; cin >> y; x+y = z; cout << z; return 0; }
23rd Sep 2016, 11:55 AM
Varmeet Singh
Varmeet Singh - avatar