0% found this document useful (0 votes)
25 views8 pages

C Language Test

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

C Language Test

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

AISECT EDUCATION

C Test
NAME - MM – 25

CLASS - OBT –

CHOOSE THE CORRECT OPTION:-

1. Who is the father of C language?


a) Steve Jobs
b) James Gosling
c) Dennis Ritchie
d) Rasmus Lerdorf

2. . Which of the following is not a valid C variable name?


a) int number;
b) float rate;
c) int variable_count;
d) int $main;
3. Which of the following is true for variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto,
static)
c) Variable names cannot start with a digit
d) Variable can be of any length
4. Which is valid C expression?
a) int my_num = 100,000;
b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;
5. What is an example of iteration in C?
a) for
b) while
c) do-while
d) all of the mentioned
6. What is #include <stdio.h>?
a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
7. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
8. What is meant by ‘a’ in the following C operation?
fp = fopen("Random.txt", "a");
a) Attach
b) Append
c) Apprehend
d) Add
9. What will be the output of the following C code?

#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value
10. Will the following C code compile without any error?

#include <stdio.h>
int main()
{
for (int k = 0; k < 10; k++);
return 0;
}
a) Yes
b) No
c) Depends on the C standard implemented by compilers
d) Error

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


#include<stdio.h>
int main()
{
int p = 1, q = 2, r = 3, s = 4, x;
e = r + s = q * p;
printf(“%d, %d\n”, x, s);
}

a. Syntax error
b. 5, 2
c. 7, 2
d. 7, 4

12. We cannot use the keyword ‘break’ simply within _________.


a. while
b. for
c. if-else
d. do-while

13. Which of the following is not related to c programming?


a. conio.h
b. getch()
c. console.log
d. All of the above

14. What does the 'printf' function do in C?


a) Input data
b) Output data
c) Perform calculations
d) Declare variables

15.What is the extension of a C source code file?


a) .c
b) .cpp
c) .exe
d) .h

16. Which keyword is used to define a constant in C?


a) var
b) const
c) constant
d) define

17.In C, which operator is used to access the value stored in a pointer variable?
a) *
b) &
c) ->
d) #

18.What is the size of an 'int' data type in C on most systems?


a) 4 bytes
b) 2 bytes
c) 8 bytes
d) Depends on the system

19.Which loop in C is used to execute a block of code as long as a condition is


true?
a) for
b) while
c) do-while
d) switch
20.What is the purpose of the 'break' statement in C?
a) Terminate a loop or switch statement
b) Continue to the next iteration of a loop
c) Print a line of text
d) Define a constant

21. Which C function is used to allocate memory dynamically?


a) malloc
b) calloc
c) realloc
d) free

22.How do you declare a character array in C to store a string?


a) char myString;
b) char[] myString;
c) char* myString;
d) string myString;

23.What is the C library function used to compare two strings?


a) strcmp
b) strcompare
c) compare
d) strcasecmp

24)Which operator in C is used for logical AND?


a) &&
b) &
c) ||
d) |

25)What is the C keyword used to define a structure?


a) struct
b) define
c) structure
d) typedef

26)What is the default return type of a C function if not specified?


a) void
b) int
c) float
d) char

27)What is the purpose of the 'goto' statement in C?


a) Loop control
b) Function declaration
c) Code branching
d) Variable declaration

28) In C, what is the operator for the modulus operation?


a) %
b) /
c) *
d) &

29) Which C header file should be included to use the 'sqrt' function?
a) math.h
b) stdio.h
c) conio.h
d) cmath.h

30)What is the ternary operator in C?


a) ?
b) :
c) ;
d) ,

31)How do you declare a pointer to an integer in C?


a) int* ptr;
b) pointer int;
c) int ptr;
d) int& ptr;

32)What is the purpose of the 'sizeof' operator in C?


a) Return the size of a variable
b) Perform arithmetic operations
c) Declare a variable
d) Allocate memory

33)What does the 'static' keyword do when used with a global variable in C?
a) Makes the variable constant
b) Limits the variable's scope to the current function
c) Retains the variable's value between function calls
d) Changes the data type of the variable

34)In C, which symbol is used to indicate a single-line comment?


a) //
b) /*
c) #
d) --
35)What is the purpose of the 'size of' operator in C?
a) Return the size of a variable
b) Perform arithmetic operations
c) Declare a variable
d) Allocate memory

36)Which data type in C is used to store characters?


a) char
b) int
c) float
d) double

37)What does the 'continue' statement do in a loop in C?


a) Exit the loop
b) Skip the current iteration and continue with the next one
c) Print a message
d) Pause the loop temporarily

38)Which library function is used to read a character from the standard input in
C?
a) scanf
b) gets
c) getchar
d) readchar

39)How is memory allocated for a C structure?


a) Automatically by the compiler
b) Using the 'malloc' function
c) Dynamically during runtime
d) Memory is not allocated for structures

40)What is the purpose of the 'union' in C?


a) To define a data structure with multiple members
b) To define a data structure that can hold different data types at the same time
c) To define a constant value
d) To declare a variable

41)Which C function is used to open a file for writing?


a) open
b) fopen
c) write
d) create
42)What is the result of the expression '5 + 2 * 3' in C?
a) 11
b) 21
c) 15
d) 10

43)What is the purpose of the 'void' keyword in C function declarations?


a) It specifies the return type of the function.
b) It indicates that the function has no arguments.
c) It specifies that the function cannot have local variables.
d) It indicates that the function does not return any value.

44)What is the escape sequence for a newline character in C?


a) \n
b) \t
c) \r
d) \

45)Which header file should be included to work with dynamic memory allocation
functions like 'malloc' and 'free'?
a) stdlib.h
b) malloc.h
c) memory.h
d) alloc.h

48)What is the purpose of the 'enum' keyword in C?


a) To define a structure
b) To define a union
c) To define a constant
d) To define a set of named integer constants

49)What does the 'sizeof' operator return in C?


a) Memory address of a variable
b) Size of the largest variable in the program
c) Size in bytes of a data type or object
d) The ASCII code of a character

50)Which C standard library function is used to sort an array of integers in


ascending order?
a) sort
b) bubbleSort
c) qsort
d) arraySort
51)Which data type is used to represent a single character in C?
a) char
b) int
c) float
d) double

52)What is the output of the following C code?


c
Copy code
int x = 5;
printf("%d", x++);
a) 5
b) 6
c) 7
d) 4

You might also like