Sunday

Mistral Placement Paper

C Section

1. What does the following program print?
#include <stio.h>
int sum,count;
void main(void)
{< BR> for(count=5;sum+=--count;)
printf("%d",sum);
}
a. The pgm goes to an infinite loop b. Prints 4791010974 c. Prints 4791001974
d. Prints 5802112085 e. Not sure

2. What is the output of the following program?
#include <stdio.h>
void main(void)
{
int i;< BR> for(i=2;i<=7;i++)
printf("%5d",fno());
}
fno()
{
staticintf1=1,f2=1,f3;
return(f3=f1+f2,f1=f2,f2=f3);
}
a. produce syntax errors b. 2 3 5 8 13 21 will be displayed c. 2 2 2 2 2 2 will be displayed
d. none of the above e. Not sure

3. What is the output of the following program?
#include <stdio.h>
void main (void)
{
int x = 0x1234;
int y = 0x5678;
x = x & 0x5678;
y = y | 0x1234;
x = x^y;
printf("%x\t",x);
x = x | 0x5678;
y = y & 0x1234;
y = y^x;
printf("%x\t",y);
}
a. bbb3 bbb7 b. bbb7 bbb3 c. 444c 4448
d. 4448 444c e. Not sure

4. What does the following program print?
#include <stdio.h>
void main (void)
{
int x;
x = 0;
if (x=0)
printf ("Value of x is 0");
else
printf ("Value of x is not 0");
}
a. print value of x is 0 b. print value of x is not 0 c. does not print anything on the screen
d. there is a syntax error in the if statement e. Not sure

5. What is the output of the following program?
#include <stdio.h>
#include <string.h>
int foo(char *);
void main (void)
{
char arr[100] = {"Welcome to Mistral"};
foo (arr);
}
foo (char *x)
{
printf ("%d\t",strlen (x));
printf ("%d\t",sizeof(x));
return0;
}
a. 100 100 b. 18 100 c. 18 18 d. 18 2 e. Not sure

6. What is the output of the following program?
#include <stdio.h>
display()
{
printf ("\n Hello World");
return 0;
}
void main (void)
{
int (* func_ptr) ();
func_ptr = display;
printf ("\n %u",func_ptr);
(* func_ptr) ();
}
a. it prints the address of the function display and prints Hello World on the screen
b. it prints Hello World two times on the screen
c. it prints only the address of the fuction display on the screen
d. there is an error in the program e. Not sure

7. What is the output of the following program?
#include <stdio.h>
void main (void)
{
int i = 0;
char ch = 'A';
do
putchar (ch);
while(i++ < 5 || ++ch <= 'F');
}
a. ABCDEF will be displayed b. AAAAAABCDEF will displayed
c. character 'A' will be displayed infinitely d. none e. Not sure

No comments: