+ 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; }

22nd Jan 2019, 4:13 PM
Akshat Nema
Akshat Nema - avatar
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
23rd Jan 2019, 9:11 AM
Sm Developer
Sm Developer - avatar
0
If you not understand it go back and read the concept of increment and descrement operators
23rd Jan 2019, 9:12 AM
Sm Developer
Sm Developer - avatar
0
Sorry your answer is wrong as it is showing some other answer while compiling it
23rd Jan 2019, 10:58 AM
Akshat Nema
Akshat Nema - avatar
23rd Jan 2019, 12:12 PM
Sm Developer
Sm Developer - avatar
0
I just give you answer for the first and it's correct 5##5##7 For first line answer
23rd Jan 2019, 12:13 PM
Sm Developer
Sm Developer - avatar