0
mujhe yeh wala program samaj main nahi aaya jab k: int a=100; b=50; toh iss ka answer 50 kaisa aaya?
#include <iostream> using namespace std; int main() { int a = 100; a = 50; cout << a; return 0; }
6 odpowiedzi
+ 2
simple, variable a declared with value 100,
then in next line value assigned '=' is 50 hence now variable value updated/overwrite.
check in program u wrote a=50 so u change variable 'a' not 'b'
+ 1
it's bcz the first time a is having 100value in it.. but on the very next line what is happening is we are again assigning the value of a equal to 50 rather than 100.. bcz in C++ the complier execute the latest value which was assign.. and in your case a=50 is the latest one.. but if you write like this
int a = 50;
a= 100;
ur output will be 100 bcz now a=100 will be the latest for compiler..
I hope it's help u bro :)
+ 1
u ask for a,b and in program there is no 'b' only a....
+ 1
bhaijaan a=50 hi output nikal raha hai.. hosakta hai ki second wala 'a' he Sayad compile hota hai
0
write in english man.see your code it is written a equals 50 in 3rd line or 4th line
- 1
see the cout statement