1. What value would be stored in an integer
variable "i" as a result of the following calculation:
int i, j; j=3;
i = 4 + 2 * j / ( j - 1 );
Solution: 7
Explanation:
j=3;
i=4+2*3/(3-1)
(Calculate the equation using operator Precedence value, Order of precedence in
equation is (),*,/,+ )
therefore, i= 7
2. In order to fetch the address of the variable we write preceding _________ sign before variable name.
Solution:
Ampersand (&)
3. What will be the output of the following
statements ?
int a = 5, b = 2, c = 10, i = a>b
void main()
{
printf("hello");
main();
}
Solution:
infinite number of times
4. A character variable can store how many
characters at a time?
Solution:
1 character
5. A pointer variable can be
Solution:
passed to a function
as argument.
6. If a = 5 and b = 7 then the statement
p=(a>b) ? a:b
Solution:
assigns a value 7 to p
7. Address stored in the pointer variable is of
type __________.
Solution: Integer
8. What will be the output of following c code
after compilation and execution?
#include<stdio.h>
int main()
{
inta=2;
if(a==2)
{
a=~a+2<<1;
printf("%d",a);
}
else {
break;
}
return0;
}
Solution:
Compiler error
9. The real numbers (numbers with decimal
fractional value) in C can be expressed which of the following forms?
Solution:
Both fractional and exponential
10. main()
{
char *p="GOOD";
char a[
]="GOOD";
printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p)
= %d", sizeof(p), sizeof(*p), strlen(p));
printf("\n sizeof(a) = %d,
strlen(a) = %d", sizeof(a), strlen(a));
}
Solution:
sizeof(p) = 2, sizeof(*p) = 1, strlen(p) = 4 sizeof(a) = 5, strlen(a) = 4
No comments:
Post a Comment