Basic
Control statements and arrays
Functions
strings
structures and ptrs
100

 The C compiler used for UNIX operating system is

  1. cc
  2. gcc
  3. vc++
  4. Borland


1. cc

(Compiler used for UNIX is 'cc' their full form is C compiler. gcc is compiler for linux. Borland and vc++ is compiler for windows.)

100

Which keyword is used to transfer control from a function back to the calling function?

  1. return
  2. go back
  3. switch
  4. goto

1. return

100

Which function finds the first occurrence of a substring in another string?

  1. strchr()
  2. strnset()
  3. strstr()
  4. None of these.

3. strstr()

100

 What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?

1) %c

2) %C

3) %s

4) %w

3) %s

100

Which operator can be used for accessing the value stored at address of a pointer variable?

  1. #
  2. *
  3. &&
  4. @

2. *


The pointer operator is,

& (address operator) = It gives address of the variable

*(Value operator) = It gives value stored at particular addre

200

Which format specifier is used for printing double value?

  1. %Lf
  2. %L
  3. %lf
  4. None of the above

3.%lf


200

Which statements are correct about an if-else statement in a C-program?

  1. Nested if-else statements are allowed.
  2. Every if-else statement can be replaced by an equivalent statement using ?: operators.
  3. Multiple statement in else block are allowed.
  4. Multiple statement in if block are allowed.


  1. 1, 3 and 4
  2. 1, 2, 3 and 4
  3. 2 , 3and 4
  4. 1 and 4

1. 1, 3 and 4

200

Which library function can change an unsigned long integer to a string?

  1. system()
  2. ltoa()
  3. ultoa()
  4. unsigned long can't be change into a string

3. ultoa()

The function ultoa() is used for converting an unsigned long integer to a string.

200

Which of the function is more appropriate for reading a multi-word string?

  1. puts()
  2. gets()
  3. printf()
  4. scanf()

2. gets()

200

Are the expression ++*ptr and *ptr++ are same?

  1. True
  2. False

2. False


++*ptr increments the value pointed by ptr and*ptr++ increments the pointer not the value.

300

What are the various types of real data type in C language?

  1. long double, short int
  2. float, long double
  3. short int, double, long int, float
  4. float, double, long double

4. float, double, long double


Floating data type is known as real data type.

There are three types of floating data type:

  • float with storage size of 4 byte
  • long double with storage size of 10 byte
  • double with storage size of 8 byte
300

 Can we use switch statement to switch on strings in C?

  1. Yes
  2. No

2. No


In switch statemen,t the cases must be either constant expression or an integer constant.

Therefore it is not allowed to use switch statement to switch on strings in C programming.

300

What is passed when we pass an array as a function argument?

  1. Base address of an array
  2. Address of the last element of array
  3. First value of elements in array
  4. All value of element in array

1. Base address of an array


On passing the name of array as function argument; the name contain the base address of an array and base address is updated inside a main function.

300

Which of the following statements are correct about string?

  1. The format specifier %s is used to print a string.
  2. The length of the string can be obtained by strlen().
  3. The pointer cannot work on string.
  4. A string is a collection of characters terminated by '\0'.


  1. 1, 4
  2. 1, 2, 3
  3. 1, 2, 4
  4. 2, 3, 4
3. 1,2,4
300

In a structure, if a variable works as a pointer then from the given below operators which operator is used for accessing data of the structure using the variable pointer?

  1. %
  2. ->
  3. .
  4. #


2. ->

For a structure, Arrow ( ->) is used for access the data using pointer variable and Dot(.) operator can be used for accessing the data using normal structure variable.

400

Which is used in mode string for opening the file in binary mode?

  1. a
  2. B
  3. b
  4. bin

3. b

For opening the file in binary mode the alphabet 'b' is used in mode string. To perform unformatted data I/O a file is opened in binary mode.

400

Which of the following statements are correct about for loop in C-program?

  1. All things that can be done using a for loop can also be done using a while loop.
  2. for loop can be used if we want statements in a loop get executed at least once.
  3. for loop works faster than a while loop.
  4. for(;;); implements an infinite loop.

The options are given below:

  1. 1
  2. 1, 2, 3
  3. 2, 3, 4
  4. 1, 2, 4

4. 1, 2, 4

400

What is the purpose of using fflush() function?

  1. Flushes only specified stream.
  2. Flushes file buffer.
  3. Flushes input/output buffer.
  4. Flushes all streams and specified buffer.

4. Flushes all streams and specified buffer.

Using "flush()" function we can flush any buffered output associated with a filename, which is either a shell command for redirecting output or a file opened for writing.

400

Which of the following statement is correct?

  1. strcmp(s1, s2) returns 0 if s1==s2
  2. strcmp(s1, s2) returns 1 if s1==s2
  3. strcmp(s1, s2) returns a number less than 0 if s1>s2
  4. strcmp(s1, s2) returns a number greater than 0 if s1<s2
  1. strcmp(s1, s2) returns 0 if s1==s2


400

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

  1. All are useful in defining new data types
  2. All are useful in defining new variable
  3. All are useful in defining new structures
  4. All are useful in defining new pointers
  1. All are useful in defining new data types
500

How would you round off a value from 1.66 to 2.0?

  1. floor(1.66)
  2. ceil(1.66)
  3. roundup(1.66)
  4. roundto(1.66)

2. ceil(1.66)

The ceil(1.66) is used for round off a value from 1.66 to 2.0. The ceil() returns upper value of a fractional part and floor() returns lower value.

500

 Which of the following statements are correct about array in C?

  1. The expression num[2] represents the very second element in the array
  2. The declaration of num[SIZE] is allowed if SIZE is a macro
  3. The array of int num[20]; can store 20 elements
  4. It is necessary to initialize array at the time of declaration


  1. 2
  2. 2,3
  3. 1,4
  4. 2,4

2. 2,3


500

For the below mention C statement, what is your comment?

signed int *p=(int*)malloc(sizeof(unsigned int));  

  1. Would throw Runtime error
  2. Improper typecasting
  3. Memory will be allocated but cannot hold an int value in the memory
  4. No problem with the statement

4. No problem with the statement


The size of int and unsigned data type is same therefore there is no problem in a C statement:

signed int *p=(int*)malloc(sizeof(unsigned int));

500

 What will be the output of the below program?

#include<stdio.h>

main()

   struct { int y;} var = {4}, *a = &var;

   printf("%d %d %d",var.y,a->y,(*a).y); 

}

  1. 4 4 garbage value
  2. 4 4 0
  3. 4 4 4
  4. Compile error


3. 4 4 4

The two possible methods of accessing structure elements using pointer is by using * or -> (arrow operator).

Therefore the output of a program is 4 4 4

500

Find out the error in the below program?


  1. struct employ  
  2. {  
  3.     int ecode;  
  4.     struct employ e;  
  5. };  
  1. Linked Error
  2. Error: in structure declaration
  3. No error
  4. None of the above

2. Error: in structure declaration


The structure employ contains a member 'e' of a same data type i.e. struct employ.

In this stage the compiler does not know the size of structure.

Therefore the compiler returns Error: in structure declaration.