C Programming and Problem Solving Questions and Answers 341 to 350

C Programming and Problem Solving

Questions 341 to 350


341.
What is/are the default storage class for functions?
I.     Auto.
II.     Register.
III.    Static.
(a)
Only (I) above
(b)
Only (II) above
(c)
Only (III) above
(d)
Both (I) and (III) above
(e)
All (I), (II) and (III) above.
342.
Find the output of the following program
int main()
{
int a[5]={1,2,3};
int i;
for(i=0;i<5;i++)
printf(“%d”,a[i]);
}
(a)
    123
(b)
      12
(c)
    321
(d)
12300
(e)
12301.
343.
What is the result of the following code?
void main( )  {
int   x = 0;
for(  x =1;  x<4;  x++ );
printf( “x=%d, ”, x);
}
(a)
x=0,
(b)
x=1,
(c)
x=3,
(d)
x=4,
(e)
x=1, x=2, x=3,.
344.
External variables are stored in which segment?
(a)
Source code segment
(b)
Heap segment
(c)
Stack segment
(d)
Data segment
(e)
Registers.
345.
Find the output of the following program
int main()
{
switch(4)
{
default:printf(“hello1”);
case1:printf(“hello2”);
case2:printf(“hello3”);
}
(a)
hello1
(b)
hello2
(c)
syntax error
(d)
Warning
(e)
hello1hello2hello3.
346.
Find  the output of the following program
int main()
{   int a=10,b=20,c;
c=add(a,b);
printf(“%d”c);
}
int add(int x,int y)
{
return(x+y);
return(x);
return(y);
return(x-y);
return(y+1);
}
(a)
  10
(b)
  20
(c)
  30
(d)
-10
(e)
  21.
347.
Find the output of the following program
int main()
{
char ch1,ch2,ch3;
ch1=’a’;
ch2=’b’;
ch3=ch1+ch2;
printf(“%d”,ch3);
}
(a)
195
(b)
 ├
(c)
-61
(d)
60
(e)
Syntax error.
348.
Find the output of the following program
int main()
{
int a,b,n;
a=100;
b=200;
n=printf(“%d%d”,a,b);
printf(“%d”,n);
}
(a)
100,200,2
(b)
100,200,100
(c)
100,200,200
(d)
100,200,6
(e)
100,200,5.
349.
Find the output of the following program
int main()
{
int i=1;
while(i<++i);
printf(“%d”,i);
}
(a)
6
(b)
5
(c)
4
(d)
3
(e)
2.
350.
Which of the following statement is incorrect?
(a)
We can compile the program without main function
(b)
We can run the program with out main function
(c)
C program consist of set of blocks
(d)
C program consist of set of statements
(e)
C program consist of set of variables.


Answers



341.
Answer : (c)
Reason  :       default storage class for function is static
342.
Answer : (d)
Reason  :       remaining elements initialize with zeros.
343.
Answer : (d)
Reason  :       for loop end with semicolon (;).
344.
Answer : (d)
Reason  :       external and static variables are stored into data segment
345.
Answer : (e)
Reason  :       there is no space between case value and no break statement in each case.
346.
Answer : (c)
Reason  :       return statement skip the remaining statements and return value to calling function
347.
Answer : (c)
Reason  :       char modifier is signed char
348.
Answer : (d)
Reason  :       printf statement returns no of characters printing on stdout device.
349.
Answer : (e)
Reason  :       ++i pre increment operator.
350.
Answer : (b)
Reason  :       we can’t run program without main function.
<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


1 comment :