+ 2
What is output in a code?
i don't understand, so i need help with this, please, i am new doing this
22 Answers
+ 13
in (b=a++) statement 'b' will be equal to the original 'a' so b=3 and then 'a' will be a=4 /it called POST_INCREMENT/
and in (++b) statement 'b' will increase by one so the output should be "4" /it called PRE_INCREMENT/
+ 5
output is just what happens onces all the code is done,the end result.after all the calculation are done its what get put into the console.basically its what gets put out.
+ 5
Input is what the program receives (from user, from evaluations, files, SQL, ETC)
Output is what the program tells you (or 'returns') !
Some find the instances such as the one you posted confusing simply because of semantics.
int a=3; a is assigned the input of 3
int b=2; b is assigned the input of 2
b=a++; b is assigned the value of a, THEN a gets +1
cout<< ++b; b gets +1 THEN is sent as OUTPUT to the console. Entirely guessing, but I'd assume output is 4?
In learning C++, input and output are pretty easy to identify:
input is any assignment ("="), request for information ("cin >>"), etc.
Output is the 'result', so to speak. Whether using cout to let you know the current state of a variable or returning a value to update one. In the above example's last line, "cout<< ++b;", we see a good example... "++b" is the input sent to cout but before it can be used, it in itself must be evaluated, since the ++ is before the b. b is incremented by one (i.e. 3+1=4),the result of which is returned by this logic. (note: RETURNED.. Output!). With "4" being the returned value, we can replace it in the initial formula..b=4; 4, the previously OUTPUT result now becomes the INPUT for b's value assignment!
+ 3
firstly you assign the value of a to b, then b = 3; after you gave it the value of 3 you then pre-increment it with 1, i.e 3+1 = 4.
+ 3
nancy :)
+ 2
it depends of the context.
In program context, the output is what your program does that affects other programs, files, or the environment where it is running. For example the console, where your program outputs printed text if no other standard output is specified (cout << text). You can also open streams to output to files, datbases, audio cards, and other devices.
Inside a program we define the output of a function. This is defined as the value that a function return if it is called/executed (can be nothing, as void functions for example). Not only custom defined functions, but also languague defined ones(+,/,--,++,etc) produces output
+ 2
In Much simpler way..if we take a simple example of cooking..
then by that way input is all the int main,return and programming stuff ( all ingredients of food) and then when we prepare the program(we cook the food with ingredients) then what we get is output (such as the cooked food )..the output is the main outcome :-)
+ 1
in this code what is the output?
int a=3;
int b=2;
b=a++;
cout<< ++b;
+ 1
4
+ 1
senan . I want learn from u .. can u help me .. I send my account on Facebook ok ... please add my friend
+ 1
senan that's my account in Facebook .. ok
https://www.facebook.com/profile.php?id=100013549546001
+ 1
answer to your question Eiver:)
int a=3;
int b=2;
b=a++;
cout<<"++b";
result:4
+ 1
a++ is the same as
int postIncrement(int &a){
int b=a;
a+=1;
return b;
}
++a is the same as:
int preIncrement( int &a){
a+=1;
return a;
}
note: because postIncrement is known to keep memory of the previous value it is a bit less efficient to use it in for loops
0
so, b=2 thats not necesary, like i see the number 2 i do not use it
0
4
0
The result of a code! Either the return value of a function or the left hand side of an assignment operator, meaning '='.
0
What is the output of the program
0
While eliminating the duplicate characters retain the first character of the characters
0
Str="school"
Str[:5]
0
Put nema of this is hacker in Eritrea people 🙄