Answers:
Q1: Output will be:
2 657
Here 657 is address of func1 in integral format.
Q2: Output will be:
10
20
30
30
Here we have given values as:
10
20
30
after that due to encounter of printf statement 30 will be printed. Now to understand this we must need to understand
what does '*' in scanf and printf means
In scanf:
When we write scanf("%*d %d",&a);
This means that the field '%*d' is to be read but ignored...
for example: If we write 12 32 ,then 12 will be ignored and 32 will be stored in a
Now in above program scanf("%d %*d %d",&a,&b);
means that 2nd field (or second value) is ignored. So values stored in a and b are 10 and 30 respectively.
In printf:
When we write printf("%nd",a);
where n is any integer like 1,2,3..... it means that the we are defining the field width.
for example: printf("%5d",1); will print 1 with 4 spaces preceding it. i.e.:
_ _ _ _ 1
Also when we write printf("%*d",a,b); it means that the field width will be a and the value printed will be b
for example: printf("%*d",5,1); will again print the above output i.e.:
_ _ _ _ 1
Q3: Output will be:
1
Explanation: In enum the values are assigned as: 0,1,2,3....
So value of second element will ofcourse be 1
Q4: Size of array must be a constant expresion, i.e. the size of array cannot be a variable whose value can be changed. To solve this we must define variable size as constant
Q5: The lines which will give errors are:
*str1='M';
*str2='K';
str3="Goodbye";
Explanation:
const char* str1
and
char const* str1 are identical expression.
now *str1 will points to first character and str1 will point to whole string.
Also, above expressions means that we cannot modify the string to which str1 points but we can modify the str1 to point to new string. So that's why *str1='M' and *str2='K' are error statements as they are modifying the string which is pointed by str1 and str2.
Also,
char * const str3
statement means that str3 will only point to one string with which it is initialized i.e. it cannot point to other string but we can modify the string to which it points. So the statement str3="Goodbye" is error statement as it trying to modify the pointer