# Output of C++ programs | Set 45

Q.1 What Is The Output Of this program?

 `#include ` `using` `namespace` `std; ` `int` `main() ` `{ ` `    ``int` `a = b = c = 10; ` `    ``a = b = c = 50; ` `    ``printf``(``"%d %d %d"``, a, b, c); ` `    ``return` `0; ` `} `

Option
a) 50 50 50
b) Three Gaebage Value
c) 10 10 10
d) Compile Time Error

`Ans: d`

Explanation : In this program, b and c are not declared and we can not directly assign the value to them so “Compilation Time” error occurred.

Q.2 What Is The Output Of this program?

 `#include ` `using` `namespace` `std; ` `int` `main() ` `{ ` `    ``double` `x = 28; ` `    ``int` `k; ` `    ``k = (``int``)x % 5; ` `    ``k = k << 2; ` `    ``printf``(``"hx=%x"``, k); ` `    ``return` `0; ` `} `

Option
a) hx = a
b) hx = 12
c) hx = c
d) hx= 13

`Ans: C`

Explanation : In this code a double value modulus an integer value is given and further the result is left shifted 2 bits and printed in hexa-decimal form.

Q.3 What Is The Output Of this program?

 `#include ` `#define squre(x) x* x ` `#define squre1(x) (x) * (x) ` `using` `namespace` `std; ` `int` `main() ` `{ ` `    ``printf``(``"%d, "``, squre(10 + 2)); ` `    ``printf``(``"%d"``, squre1(10 + 2)); ` `    ``return` `0; ` `} `

Option
a) 144, 32
b) 32, 144
c) 100, 12
d) 12, 144

`Ans: B`

Explanation : In this program, #define macro used to replace value and calculated them like this:

```10 + 2 * 10 + 2 = 32
or (10+2)*(10+2) = 144 ```

Q.4 What Is The Output Of this program?

 `#include ` `using` `namespace` `std; ` `int` `main() ` `{ ` `    ``int` `i; ` `    ``i = 0x18 + 0110 + 11; ` `    ``printf``(``"p= %d"``, i); ` `    ``return` `0; ` `} `

Option
a) p= 101
b) p= 107
c) p= 40
d) Error

`Ans: B`

Explanation : In this program 0x is hexa-decimal notation and 0 is octal, convert these value in decimal and add them.

Q.5 What Is The Output Of this program?

 `#include ` `using` `namespace` `std; ` `int` `main() ` `{ ` `    ``char``* a = ``"INFO"``; ` `    ``a++; ` `    ``printf``(``"%s"``, a); ` `    ``return` `0; ` `} `

Option
a) Error
b) INFO
c) NFO
d) None of these

`Ans: C`

Explanation : In this program, *a is hard core string that contain a base address of string. When we increment the address, it points to next value of the string.

This article is contributed by Gyayak jain . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.