C Question
C Question
Question 1
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
struct emp
char name[20];
};
A. 0 0.000000
B. Garbage values
C. Error
Q2)
Which of the following is not a user-defined data type?
A.
struct book
{
char name[10]; int pages;
float price;
};
B.
C.
D.
union a
{
int i;
char ch[2];
};
Control instructions
Question 3
#include <stdio.h>
void main()
int i = 1;
switch (i)
{
case 1:
Question 4
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
int a = 300, b, c;
if (a >= 400)
b = 300;
c = 200;
printf ("\n%d %d %d", a, b, c);
}
Question 5
Which of the following statements are correct about the program given below?
#include <stdio.h>
void main()
{
int x = 30, y = 40;
if (x == y)
else if (x >y)
else if (x<y)
Question 6
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main() {
int i = 0;
A. 0 1 2 3 4
B. 5
C. 1 2 3 4
D. 6
Question 7
On executing the following program how many times would the message "Keep it up"
would get printed?
#include <stdio.h>
void main()
{
int x;
if (x<5) continue;
else
break;
A. Infinite times
B. 11 times
C. 0 times
D. Once
E. 10 times
Expressions
Question 8
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
int x = 4, y, z;
y=-x;
Z=x-;
A. 4 3 3
B. 4 3 2
C. 3 3 2
D. 2 3 3
E. 2 2 3
Question 9
Which of the following is the correct output for the program below? program give
#indude <stdio.h>
void main()
{
float a=0.7;
if(a<0.7f)
printf ("C");
else
printf ("C++");
}
A. C
B. C++
Functions
Question 10
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
int i=1;
if(!i)
printf ("Recursive calls are painful\n");
else
i=0;
printf ("Recursive calls are challenging\n");
main();
}
}
Question 11
#include <stdio.h>
void main()
{
printf ("\nJamboree");
main();
B. 32767 times
C 65535 times
Question 12
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
int fun (int);
int i = fun (10);
printf ("%d\n", -i);
}
int fun (int i)
{
return (i++);
A. 9
B. 10
C. 11
D. 8
Question 13
Which of the following is the correct output for the program given below?
#indude <stdio.h>
void fun (int);
void main()
{
int a;
a=3;
fun (a);
}
fun (-n);
}
A. 0210
B 1120.
C 0102
D 0120
Question 13
Which of the following statements are correct about the program given below?
#include<stdio.h>
int reverse (int);
void main()
{
int no = 5;
reverse (no);
else
printf("%d", o);
reverse (no--);
}
A. Program outputs values 5 4 3 2 1.
The C preprocessor
Question 14
#include <stdio.h>
void main()
A. 10
B. 20
C. 1020
D. 12
Pointers
Question 15
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
}
A. 1
B. 10
C. 0
Question 16
What will be the output of the following program, if the array begins at 65486 and
each integer occupies 2 bytes?
#include <stdio.h>
void main()
{
int arr[] = {12, 14, 15, 23, 45);
Question 17
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
int i;
for(i=0;i<4;i++)
printf ("%d", arr[i]);
}
void fun (int n, int arr[])
{
int *p = 0;
int i = 0;
while (i++<n)
p=&arr[i];
*p = 0;
A. 2 3 4 5
B. 1 2 3 4
C. 0 1 2 3
D. 3 2 1 0
Question 18
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
char str[7]="Strings";
printf ("%s", str);
A. Error
B. Strings
C. Cannot predict
Question 19
#include <stdio.h>
void main()
struct emp
char name[ 25 ];
float bs;
int age;
};
struct emp e
e.name = "Rahul";
e.age = 25;
Question 20
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
static char *s[] = { "black", "white", "pink", "violet" };
char **ptr[] = {s+3, s +2, s +1, s}, ***p;
p = ptr;
++p;
printf ("%s". **p+1);
A. ink
B. ack
C. ite
D. let
Array
Question 21
Which of the following is the correct output for the program given
below?
#include <stdio.h>
void main()
{
static int arr[] = {0, 1, 2, 3, 4);
int *p[]= (arr, arr + 1, arr +2, arr +3, arr + 4);
int **ptr = p;
ptr++;
*ptr++;
*++ptr;
++*ptr ;
printf ("\n%d %d %d", ptr - p. "ptr - arr, *ptr);
Question 22
Question 23
What will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?
Strings
Question 24
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
char t;
p2 = p1;
Question 25
Which of the following is the correct output for the program given below?
#include <stdio.h>
#include <string.h>
void main()
{
char str1[20] = "Hello", str2[20] = " World";
A. Hello
B. World
C. Hello World
D. WorldHello
Question 26
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
char str[]="Nagpur";
str = "Kanpur";
str="Kanpur";
printf ("%s", str +1);
}
A. Kagpur Kanpur
B. Nagpur Kanpur
C. Kagpur anpur
D. Error
Question 27
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
enum days {MON =-1, TUE, WED = 6, THU, FRI, SAT };
A. -101234
B. Error
C. 016345
D. 006789
Question 28
Which of the following statements are correct about the program given below?
#indude <stdio.h>
void main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e[2];
int i=0;
for(i=0;i<2; i++)
Question 29
#indude <stdio.h>
struct date
{
int day ;
int month;
int year;
};
void main()
struct date d;
struct date *pdt;
pdt = &d;
B. &pdt.month = 12;
C. d.month= 12;
Input /Output
Question 30
Which of the following is the correct output for the program given below?
#include <stdio.h>
void main()
{
FILE *fp;
fp = fopen("try.c", "T");
/*try.c exists and contains "This is Nagpur" "/
fseek (fp, 9L, SEEK_CUR);
fgets (str. 5, fp);
puts (str);
A. agpur
B. gpur
C. Nagp
D. agpu
31) Given the following statement, what will be displayed on the screen?
int * aPtr;
*aPtr = 100;
cout << *aPtr + 2;
A. 100
B. 102
C. 104
D. 108
A. p1 = p1 + p2;
B. p1 = p1 - 9;
C. p2 = p2 + 9;
D. cout << p1 - p2;
35) If addition had higher precedence than multiplication, then the value of the
expression (1 + 2 * 3 + 4 * 5) would be which of the following?
A. 27
B. 47
C. 69
D. 105