This is a mock Exam for the C programmers. It is created by Genesis InSoft Limited
(admin@genesisinsoft.com)
and may be freely distributed so long as it is unmodified. Please email us if you
have any corrections or comments.
The number of components in a doubly linked list is
- 1
- 2
- 3
- 4
Answer to Question 1
What is the output of the program?
#include <stdio.h>
void main()
{
unsigned short a = -4;
// Assume short is 2 bytes
printf("\n %u", a);
}
- Error: Variable of type unsigned char cannot store negative values
- 4
- -4
- 65532
Answer to Question 2
Which of the following is a non-linear data structure?
- Stack
- Queue
- Linked List
- Tree
Answer to Question 3
Function time (time_t*) is used to get the
- current system time
- time taken for the program to execute
- file updation time
- file creation time
Answer to Question 4
Macros
- Expands the code size
- Perform dumb substitution
- Reduce the speed of program execution
- Both A and B
Answer to Question 5
Which of the options helps the programmer in debugging a program?
- Watch
- Building a project
- Conditional compilation
- Both A and C
Answer to Question 6
How can you correct improper naming of function?
- By type defining the function
- By declaring pointer to functions
- By # defining the name
- By redefining the function
Answer to Question 7
Memory conservation is possible using
- Unions
- Static variables
- Arrays
- Bit fields
Answer to Question 8
What is the output of the program?
#include <stdio.h>
#define MAX 20
void main()
{
printf("%d", ++MAX));
}
- No error, output is 20
- No error, output is 21
- Error: Define directive needs an identifier
- Error: Lvalue required
Answer to Question 9
What is the output of the program?
#include <stdio.h>
#define SQ(a) a*a
void main()
{
printf("%d", SQ(2+3));
}
- 11
- 25
- Error in compilation
- 13
Answer to Question 10
'C' language was developed to achieve
- Portability
- Modularity
- Platform independence
- Reusability
Answer to Question 11
How many bytes are allocated for "int" declaration?
- minimum 2
- only 2
- minimum 4
- only 4
Answer to Question 12
Which of the following data types has the same size irrespective of the operating
system?
- char*
- int
- float
- char
Answer to Question 13
What is the output of the program?
#include <stdio.h>
void main()
{
int m = (m = 1, m++, --m);
printf("\n %d ", m);
}
- Error: undefined symbol 'm'
- 2
- 1
- 3
Answer to Question 14
What is the output of the program?
#include <stdio.h>
void main()
{
printf("%d", sizeof(int) ?
1 ? 2 : 3 ? 4 : 5);
}
- Error: Lvalue required
- syntax error: missing : before )
- 2
- 3
Answer to Question 15
A switch statement is similar to
- while
- do - while
- multiple if - else if - else
- for
Answer to Question 16
Which of the following function returns an integer data type?
- strncpy
- strcmp
- strstr
- strcat
Answer to Question 17
Which of the following statements is correct?
- when a pointer is incremented by 1 the address contained in the pointer is incremented
by 1
- when a pointer is incremented by 1 the address contained in the pointer is incremented
by size of integer
- when a pointer is incremented by 1 the address contained in the pointer is incremented
according to the type of pointer
- when a pointer is incremented by 1 the address contained in the pointer is incremented
according to the type it is pointing to
Answer to Question 18
What is the output of the program?
#include <stdio.h>
void main()
{
static int a[] = {5, 10, 15, 20};
int* ptr = a;
int** ptr_ptr = &ptr;
printf("\n %d",**ptr_ptr++);
}
- 5
- 10
- 15
- 20
Answer to Question 19
The compiler evaluates the operator '*' as either a pointer indirection or multiplication
based on
- the operator precedence
- the number of operands
- the type of operands
- its location in the source code
Answer to Question 20
Answers
Answer 1 - C
Back to question 1
Answer 2 - D
Back to question 2
Answer 3 - D
Back to question 3
Answer 4 - A
Back to question 4
Answer 5 - D
Back to question 5
Answer 6 - D
Back to question 6
Answer 7 - B
Back to question 7
Answer 8 - D
Back to question 8
Answer 9 - D
Back to question 9
Answer 10 - A
Back to question 10
Answer 11 - A
Back to question 11
Answer 12 - A
Back to question 12
Answer 13 - D
Back to question 13
Answer 14 - C
Back to question 14
Answer 15 - B
Back to question 15
Answer 16 - C
Back to question 16
Answer 17 - B
Back to question 17
Answer 18 - C
Back to question 18
Answer 19 - A
Back to question 19
Answer 20 - B
Back to question 20