What is output in a code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is output in a code?

i don't understand, so i need help with this, please, i am new doing this

24th Nov 2016, 1:47 AM
Eiver
Eiver - avatar
21 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/
24th Nov 2016, 3:55 AM
Senan
Senan - avatar
+ 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.
24th Nov 2016, 3:34 AM
Ángel Perales
Ángel Perales - avatar
+ 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!
24th Nov 2016, 1:32 PM
Matthew Shephard
Matthew Shephard - avatar
+ 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.
24th Nov 2016, 4:28 PM
ARB
ARB - avatar
+ 3
nancy :)
24th Nov 2016, 8:33 PM
alex “TrollingYT”
alex “TrollingYT” - avatar
+ 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
24th Nov 2016, 11:44 PM
Federico Beltrame
Federico Beltrame - avatar
+ 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 :-)
25th Nov 2016, 5:48 PM
Tanu Purohit
Tanu Purohit - avatar
+ 1
in this code what is the output? int a=3; int b=2; b=a++; cout<< ++b;
24th Nov 2016, 3:40 AM
Eiver
Eiver - avatar
+ 1
4
24th Nov 2016, 1:51 PM
Ángel Perales
Ángel Perales - avatar
+ 1
senan . I want learn from u .. can u help me .. I send my account on Facebook ok ... please add my friend
27th Nov 2016, 7:41 PM
amr
+ 1
senan that's my account in Facebook .. ok https://www.facebook.com/profile.php?id=100013549546001
27th Nov 2016, 7:48 PM
amr
+ 1
answer to your question Eiver:) int a=3; int b=2; b=a++; cout<<"++b"; result:4
27th Nov 2016, 11:46 PM
Tanu Purohit
Tanu Purohit - avatar
+ 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
5th Dec 2016, 4:32 AM
Federico Beltrame
Federico Beltrame - avatar
0
so, b=2 thats not necesary, like i see the number 2 i do not use it
24th Nov 2016, 3:38 PM
Eiver
Eiver - avatar
0
4
24th Nov 2016, 5:30 PM
Yash Trivedi
Yash Trivedi - avatar
0
The result of a code! Either the return value of a function or the left hand side of an assignment operator, meaning '='.
25th Nov 2016, 12:57 PM
Saeed Ghasemi
Saeed Ghasemi - avatar
0
What is the output of the program
20th Jul 2022, 6:45 PM
Md WahidQuar
Md WahidQuar - avatar
0
While eliminating the duplicate characters retain the first character of the characters
21st Jan 2023, 10:00 AM
Sairakesh Sairakesh
Sairakesh Sairakesh - avatar
0
Str="school" Str[:5]
24th Mar 2023, 11:54 PM
Rehan khan
0
Put nema of this is hacker in Eritrea people 🙄
21st Apr 2023, 6:14 AM
Fidel Fsshaye
Fidel Fsshaye - avatar