Sei sulla pagina 1di 6

Section I: Objective

1. How many x's are printed?

for (i = 0, j = 10; i < j; i++, j--)


printf ("x");

A) 10 B) 5 C) 4 D) none

2. x = malloc (y). Which of the following statements is correct?

A) x points to the memory allocated B) y points to the memory allocated

C) x is the size of the memory allocated D) none of the above

3. What is the output of this C code?

int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
return 0;
}

A) Compilation error B) unequal C) equal D) Depends on the compiler

4. The continue command cannot be used with?

A) for B) if C) do D) while

5. What would be the output of the following program?

int main()
{
int a, b = 5;
a = b + NULL;
printf(“%d”, a);
return 0;
}

A) 6 B) 5 5 C) 5 D) None
6. How to deallocate memory in *ptr without using free()?
int *ptr = (int*) malloc(10);

7. What will be the output of the following program code?

void main()
{
int i = 5, j = 6, z;
printf("%d", i+++j);
}

A) 12 B) 11 C) 13 D) none of these

8. What would be the equivalent pointer expression for referring the array
element a[i][j][k][l]?

A) ((((a+i)+j)+k)+l) B) *(*(*(*(a+i)+j)+k)+l)
C) (((a+i)+j)+k+l) D) ((a+i)+j+k+l)

9. What is the output of the following program?

#include<stdio.h>
void main()
{
int a[] = {10, 20, 30};
printf("%d", *a+1);
}

A) 10 B) 20 C) 11 D) 21

10. If a variable is a pointer to a structure, then which of the following operator is used to
access data members of the structure through the pointer variable?

A) . B) * C) & D) ->

11. What will be the output of the following program code?

for(i = 10; i++; i < 15)


printf("%d ", i);

A) 10 11 12 13 14 B) error C) infinite loop D) 10 11 12 13 14 15

12. Given b=110 and c=20, what is the value of 'a' after execution of the expression
a = b -= c *= 5?

A) 450 B) -10 C) 10 D) 110


13. When a function is recursively called all the automatic variables are stored in?

A) Queue B) Stack C) Register D) Linked list

14. Consider the following program and choose the correct one ?

void main()
{
int a, b = 2, c;
a = 2 * (b++);
c = 2 * (++b);
printf(“a = %d, c = %d”, a, c);
}

A) a = 4, c = 8 B) a = 3, c = 8 C) b = 3, c = 6 D) a = 4, c = 6

15. What is the output of the following program?

void main()
{
int i = 1, j = -1;
if((printf("%d", i)) < (printf("%d", j)))
printf("%d", i);
else
printf("%d", j);
}

A) 1 -1 1 B) 1 -1 -1 C) 1 D) complier error

16. What is the similarity between a structure, union and enumeration?

A) All of them let you define new values


B) All of them let you define new data types
C) All of them let you define new pointers
D) All of them let you define new structures

17. What is the output of the below program?

void main()
{
int a = 1, b;
b = a++ + ++a + a++;
printf("%d\t%d", b, a);
}

A) 4 4 B) 5 4 C) 6 4 D) 7 4
18. Which operator from the following has the lowest priority?

A) Assignment operator B) Division operator


C) Comma operator D) Conditional operator

19. What is the output of the below program?

int main()
{
printf(“Resonous”);
main();
return 0;
}

A) Compilation error B) Run time error


C) Print Resonous till stack overflows D) Print Resonous 65535 times

20. In case of a conflict between the names of a local and global variable what happens?

A) The global variable is given a priority.


B) The local variable is given a priority.
C) Which one will get a priority depends upon which one is defined first.
D) The compiler reports an error.

21. What is the output of the following program?

void main()
{
int i = 10;
printf("%d ", i);
{
int i = 20;
printf("%d ", i);
i++;
printf("%d ", i);
}
printf("%d ", i);
}

A) 10 10 11 11 B) 10 20 21 21 C) 10 20 21 20 D) 10 20 21 10

22. Which of the following function is more appropriate for reading in a multi-word string?

A) puts() B) printf() C) gets() D) scanf()


23. Which is the correct sequence of compilation process?

A) Assembler → Compiler → Preprocessor → Linking


B) Compiler → Assembler → Preprocessor → Linking
C) Preprocessor → Compiler → Assembler → Linking
D) Assembler → Compiler → Linking → Preprocessor

24. Point out the error in the following program?

int main()
{
char* ptr;
*ptr = (int*)malloc(30);
strcpy(ptr, "RAM");
printf("%s", ptr);
free(ptr);
return 0;
}

A) Error: in strcpy() statement.


B) Error: in *ptr = (int *) malloc(30);
C) Error: in free(ptr);
D) No error

25. What is the output of the following program?

#include<stdio.h>
int c[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
main()
{
int a, b=0;
for(a = 0; a < 10; ++a)
if(c[a]%2 == 1)
b += c[a];
printf("%d", b);
}

A) 20 B) 25 C) 24 D) 30
Section II: Descriptive

26. Write a C-program to finding the given number is a Palindrome or not?

27. Write a C-program to finding the given number is EVEN or ODD without using Arithmetic
Operators?

28. Write Fibonacci series program in c using recursion?

29. Write a C program to print the given number in words?

30. Write a C Program to Add Two Complex Numbers by Passing Structure to a Function?

Potrebbero piacerti anche