Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

1. What will be the output of the program?

#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}

A. Hi

B. Hello

C. Hi Hello

D. None of above
2. Are the properties of i, j and x, y in the following program same?
typedef unsigned long int uli;
uli i, j;
unsigned long int x, y;

A. Yes

B. No
3. Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
unsigned char;
FILE *fp;
fp=fopen("trial", "r");
if(!fp)
{
printf("Unable to open file");
exit(1);
}
fclose(fp);
return 0;
}

A. Error: in unsigned char statement


B. Error: unknown file pointer

C. No error

D. None of above
4. Which of the following cannot be checked in a switch-case statement?
A. Character

B. Integer

C. Float

D. enum
5. Point out the error in the program?
#include<stdio.h>

int main()
{
struct a
{
float category:5;
char scheme:4;
};
printf("size=%d", sizeof(struct a));
return 0;
}

A. Error: invalid structure member in printf

B. Error in this float category:5; statement

C. No error

D. None of above
6. Bitwise can be used to perform addition and subtraction.
A. Yes

B. No
7. Point out the error in the program.
#include<stdio.h>
#define MAX 128

int main()
{
char mybuf[] = "India";
char yourbuf[] = "BIX";
char *const ptr = mybuf;
*ptr = 'a';
ptr = yourbuf;
return 0;
}

A. Error: unknown pointer conversion

B. Error: cannot convert ptr const value

C. No error

D. None of above
8. What will be the output of the program?
#include<stdio.h>

int main()
{
typedef float f;
static f *fptr;
float fval = 90;
fptr = &fval;
printf("%f\n", *fptr);
return 0;
}

A. 9

B. 0

C. 90.000000

D. 90
9. Data written into a file using fwrite() can be read back using fscanf()
A. True

B. False
10. What will be the output of the program (in Turbo C)?
#include<stdio.h>

int fun(int *f)


{
*f = 10;
return 0;
}
int main()
{
const int arr[5] = {1, 2, 3, 4, 5};
printf("Before modification arr[3] = %d", arr[3]);
fun(&arr[3]);
printf("\nAfter modification arr[3] = %d", arr[3]);
return 0;
}

Before modification arr[3] = 4


A.
After modification arr[3] = 10

B. Error: cannot convert parameter 1 from const int * to int *

C. Error: Invalid parameter

Before modification arr[3] = 4


D.
After modification arr[3] = 4
11. What will be the output of the program ?
#include<stdio.h>

int main()
{
printf("%c\n", ~('C'*-1));
return 0;
}

A. A

B. B

C. C

D. D
12. What will be the output of the program?
#include<stdio.h>
#define CUBE(x) (x*x*x)

int main()
{
int a, b=3;
a = CUBE(b++);
printf("%d, %d\n", a, b);
return 0;
}

A. 9, 4

B. 27, 4

C. 27, 6

D. Error
13. What will be the output of the program (sample.c) given below if it is executed from the
command line?
cmd> sample monday tuesday wednesday thursday
/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])


{
while(--argc>0)
printf("%s", *++argv);
return 0;
}

A. sample monday tuesday wednesday thursday

B. monday tuesday wednesday thursday

C. monday tuesday thursday

D. tuesday
14. If the following structure is written to a file using fwrite(), can fread() read it back
successfully?
struct emp
{
char *n;
int age;
};
struct emp e={"IndiaBIX", 15};
FILE *fp;
fwrite(&e, sizeof(e), 1, fp);

A. Yes

B. No
15. Point out the error in the program?
#include<stdio.h>

int main()
{
unsigned int a, b, c, d, e, f;
a=b=c=d=e=f=32;
a<<=2;
b>>=2;
c^=2;
d|=2;
e&=2;
f~=2;
printf("%x %x %x %x %x %x\n", a, b, c, d, e, f);
return 0;
}
A. Error: printf() statement

B. Error: d|=2; statement

C. Error : f~=2; statement

D. No error
16. What will be the output of the program ?
#include<stdio.h>

int main()
{
char p[] = "%d\n";
p[1] = 'c';
printf(p, 65);
return 0;
}

A. A

B. a

C. c

D. 65
17. What will be the output of the program ?
#include<stdio.h>

int main()
{
static char s[25] = "The cocaine man";
int i=0;
char ch;
ch = s[++i];
printf("%c", ch);
ch = s[i++];
printf("%c", ch);
ch = i++[s];
printf("%c", ch);
ch = ++i[s];
printf("%c", ch);
return 0;
}

A. hhe!

B. he c

C. The c
D. Hhec
18. What will be the output of the program?
#include<stdio.h>

int addmult(int ii, int jj)


{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}

int main()
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d %d\n", k, l);
return 0;
}

A. 12 12

B. No error, No output

C. Error: Compile error

D. None of above
19. Left shifting an unsigned int or char by 1 is always equivalent to multiplying it by 2.
A. True

B. False
20. Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>

int main()
{
void display(int num, ...);
display(4, 12.5, 13.5, 14.5, 44.3);
return 0;
}
void display(int num, ...)
{
float c; int j;
va_list ptr;
va_start(ptr, num);
for(j=1; j<=num; j++)
{
c = va_arg(ptr, float);
printf("%f", c);
}
}

A. Error: invalid va_list declaration

B. Error: var c data type mismatch

C. No error

D. No error and Nothing will print

You might also like