Skip to main content

ads by adstra

A-ads

C Fundamental Test 1


1) Which of the following is the first operating system developed using C programming language?

  1. Windows
  2. DOS
  3. Mac
  4. UNIX

The correct option is (d).

Explanation:

C programming language is invented for developing an operating system called UNIX. By 1973, the complete UNIX OS is developed using C.

2) The C compiler used for UNIX operating system is

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

The correct option is (a).

Explanation:

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

3) Which of the following is a logical AND operator?

  1. ||
  2. !
  3. &&
  4. None of the above

The correct option is (c).

Explanation:

The && is called logical AND operator. If both operands are non-zero, then the condition becomes true.

The || is called logical OR operator. If any of the two operands are non-zero, then the condition becomes true.

The ! is called logical NOT operator. It is used for reversing the logic state of its operand.

4) Which format specifier is used for printing double value?

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

The correct option is (c).

Explanation:

The %lf format specifier is used for printing the double value in a C program.

5) Which of the following statement is used to free the allocated memory space for a program?

  1. vanish(var-name);
  2. remove(var-name);
  3. erase(var-name);
  4. free(var-name);

The correct option is (d).

Explanation:

The memory allocated by malloc(), calloc(), or realloc() function is deallocated by using the library function free(var-name).


6) In a library of C programming language, which of the following header file is used for performing mathematical operations?

  1. conio.h
  2. dos.h
  3. math.h
  4. stdio.h

The correct option is (c).

Explanation:

"math.h" is a header file used for performing mathematical operation in a library of C programming language.

7) 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

The correct option is (d).

Explanation:

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

8) The statement used for printing \n on the screen is:

  1. printf("");
  2. printf('\n');
  3. printf("\\n");
  4. printf("n\");

The correct option is (c).

Explanation:

In C language,"\n" is the escape sequence for printing a new line character. For a statement printf("\\n"); statement , "\\" symbol will be printed as "\" and "n" is known as a common symbol.

9) Which of the following are declarations?

  1. float square (float x){?}
  2. double pow(double, double);
  3. extern int x;

Options are given below:

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

The correct option is (b).

Explanation:

double pow(double, double); instruction is a function prototype declaration

extern int x; instruction is an external variable declaration.

Therefore 1 and 3 are declarations and 2 is definition.

10) Which header file is used to define input/output functions, macros and prototypes?

  1. memory.h
  2. math.h
  3. dos.h
  4. stdio.h

The correct option is (d).

Explanation:

Header file stdio.h is used for defining the macros, variable and various functions for performing input and output operation in C-language.


11) Single line comment in C language begins with _______

  1. :
  2. //
  3. */
  4. /*

The correct option is (b).

Explanation:

For giving the comment in single line two immediate forward slashes are used. For a multi line comment it begins with /* and should be terminated with */.

12) What is the data type of "PI" for the below statement:

  1. #define PI 3.141   
  1. Float data type
  2. Double datatype
  3. There is no data type associated with PI
  4. Syntax error, semi colon is missing with definition of PI

The correct option is (c).

Explanation:

Text associated with macro statement gets expanded at line of call. The expanded text is by default a constant with no data type associated with PI.

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

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

The correct option is (b).

Explanation:

The pointer operator is,

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

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

14) The types of linkages in C programming language are:

  1. External linkage and None linkage
  2. Internal linkage and None linkage
  3. Internal linkage, External linkage and None linkage
  4. Internal linkage and External linkage

The correct option is (c).

Explanation:

  • Internal linkage: A functions and static variables with file scope.
  • External linkage: A global, functions and non-static variables.
  • None linkage: A local variables.

15) Which of the following is true about C Programming?

  1. Platform Independent
  2. High level language
  3. Machine Independent
  4. Assembly language

The correct option is (c).

Explanation:

C-programming language is machine independent programming language. It provides the feature of portability of code means source code written on one machine can be run on any other machines.


16) What is the correct value returned to the operating system upon successful completion of a program?

  1. 0
  2. -1
  3. 1
  4. Programs do not return a value

The correct option is (a).

Explanation:

After successful completion of a program, 0 is returned to the operating system.

17) Who is known as the founder of C language?

  1. James Gosling
  2. Martin Richard
  3. Brian Kernighan
  4. Dennis Ritchie

The correct option is (d).

Explanation:

The C programming language has been developed by Dennis Ritchie in the year 1972 while working at AT&T Bell Laboratories.

18) The C variables are case insensitive.

  1. True
  2. False

The correct option is (b).

Explanation:

The C variables are case sensitive. This means that variables sal, Sal and SAL would be treated as different variables in C.

19) A character variable can store ___ character(s) at a time.

  1. 1
  2. 2
  3. 0
  4. NULL

The correct option is (a).

Explanation:

A character variable can at a time store only one character. In fact, if we execute the following statements, what gets stored in variable ch is not really the character constant, but the ASCII value of 'A', which is 65.

  1. char ch;  
  2. ch'A';  

20) 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)

The correct option is (b).

Explanation:

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.

  1. /* Example for floor() and ceil() functions:*/  
  2. #include<stdio.h>  
  3. #include<math.h>  
  4. int main()  
  5. {  
  6. printf("\n Result : %f" , ceil(1.44) );  
  7. printf("\n Result : %f" , ceil(1.66) );  
  8. printf("\n Result : %f" , floor(1.44) );  
  9. printf("\n Result : %f" , floor(1.66) );  
  10. return 0;  
  11. }  
  12. // Output:  
  13. //Result : 2.000  
  14. //Result : 2.000  
  15. //Result : 1.000  
  16. //Result : 1.000