# Guess The Output series 5

Explanation of guess the output questions posted on our Instagram Page.

## 1) Guess the output

The output of above C Program is D) 3 -2.
Why?
Initially the values of m and n are 5 and 3 respectively.
`a += b `is same as `a = a+b`
`a -= b `is same as `a = a-b`
`a *= b `is same as `a = a*b`
`a /= b `is same as `a = a/b`
`a %= b `is same as `a = a%b`
and so on…

The above expression
`m += n -= m` acts like `m = m + (n = n-m);`
First of all, bracket will execute so the value of n becomes
`n = n - m `i.e.` n = 3 - 5`.` n = -2`
The updated expression looks like
`m = m + (-2)`
Final value of m is `m = 5 - 2` which is equal to 3.

So the output of above C Program is `3 -2`.

Click on Execute button to Run above code:

## 2) Question On Array

We know that 1[arr] is same as arr. Initially arr is filled with garbage values.
Then 5 is assigned to arr and 10 is assigned to arr.
printf(“%d”, -1[arr]) is nothing but printf(“%d”, – arr). The value at arr is 10.
So the output of above C Program is -10.

Click on Execute button to Run above code:

## 3) Type Casting

The output of above C Program is B) 49.
ASCII equivalent of the character will be displayed in conversion of char to int in C/C++ Programming Language.
The ASCII value of 0 is 48, 1 is 49 and so on.
You can print ASCII values and equivalent character using C or C++ Language.

``````//Program to Print ASCII Value and its equivalent character
#include<stdio.h>

int main() {
int i;
for(i=48; i<100; i++)
{
printf("%d : %c \n", i, i);
}

return 0;

}``````

Click on Execute button to Run above code:

## 4) Switch Case

Output of above C Program is C) 20.
We can place default block anywhere inside switch. It will execute if no cases matched.
The statements which are written above cases (i.e. m = m+10;) never executes. The control is transfer to the matching case so the statements written above case not executed.

## 5) printf in C

The syntax of printf is
`int printf (const char* c-string, …);`
Where `c-string` is the string passed to printf function. If there is format specifiers(i.e. %d, %c, %p …) in the c-string then additional arguments can be passed with c-string.

f in printf(print formatted) stands for formatted not function.

First of all, printf(3+”hello”) is same as printf(“hello”+3).
The length of “hello” is 5. 3+”hello” means skip first 3 characters(i.e. hel) and print the remaining characters(i.e. lo)

Above code can be written like this

``````#include<stdio.h>
int main()
{
int hello = 1;
char *str = "hello";
printf(str+3);

return 0;
} ``````

The output of above C Program is D) lo 