+ 1
What is the output of below code of C++ and give its logic
#include <iostream> using namespace std; int main() { int a=5,b=7; char c='D',d='a'; cout<<"\n"<<a<<"##"<<a++<<"##"<<++a; cout<<"\n"<<++b<<"&&"<<b++<<"&&"<<b+1; cout<<"\n"<<--c<<"@@"<<c<<"@@"<<c--; cout<<"\n"<<++d<<"$"<<d++<<"$"<<++d; return 0; }
5 Answers
0
I tell you the logic for only first line
"/n" for new line
a = 5
##
a++ = 5 // but it chages the value of intaitial a to 6
##
++a = 7
as a = 6 before
The ++a increment both new and old value
The final answer for the first line is
5##5##7
0
If you not understand it go back and read the concept of increment and descrement operators
0
Sorry your answer is wrong as it is showing some other answer while compiling it
0
I just give you answer for the first and it's correct
5##5##7
For first line answer