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; }
12 Réponses
+ 7
z=x+y and x+y=z have different meaning in c++?
+ 6
x+y >>z ?
do you want assign x+y to z?
right way to do it is:
z = x +y;
+ 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;
}
+ 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
+ 1
Try z=x+y
0
gave an error.
0
put int values INSIDE main ()
0
What I have to do, if I want to change integer numbers to double float-pointed numbers?
0
x+y>>z should be z=x+y;
- 2
put x+y =z;
it will work
- 2
declate x,y,x inside the curly brackets, after the "int main()" declaration
- 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;
}