Question For C Programing Rajesh

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

(1) C language was developed by_____.

a) Dennis Rechard b) Dennis M. Ritchie


c) Bjarne Stroustrup d) Anders Hejlsberg

(2) C language is a successor to which language?


a) Basic b) Cobol
c) C++ d) B

(3) C is a _______.
a) Low level language b) High level language
c) Medium level language d) None of the above

(4) How many keywords are there in C language?


a) 32 b) 33
c) 64 d) 18

(5) Which is not a valid keyword in C language?


a) For b) while
c) do-while d) switch

(6) A C-style comment, simply surround the text with ___.


a) /* and */ b) // and //
c) // d) /** and **/

(7) What is the extension of a C language header file?


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

(8) Which is/are the disadvantage(s) of C language?


a) No Garbage Collection b) Inefficient Memory Management
c) Low level of abstraction d) All of the above

(9) Which is the correct format specifier for double type value in C?
a) %d b) %f
c) %lf d) %LF

(10) The short type represents ___.


a) Int b) float
c) unsigned int d) short int

(11) What is the correct syntax to declare a variable in C?


a) data_type variable_name; b) data_type as variable_name;
c) variable_name data_type; d) variable_name as data_type;
(12) Which is correct with respect to the size of the data types in C?
a) char > int > float b) char < int < float
c) int < char < float d) int < chat > float

(13) Which operator is used to find the remainder of two numbers in C?


a) / b) \
c) % d) //

(14) What will be the output of the following C code?


#include <stdio.h>
int main()
{
float x = 21.0;
x %= 3.0;
printf("%f",x);
return 0;
}
a) 7 b) 7.00
c) 7.000000 d) Error

(15) Increment (++) and decrement (--) are the ___ operators in C?
a) Unary b) Binary
c) Ternary d) None of the above

(16) Which of the following are valid decision-making statements in C?


a) If b) switch
c) nested if d) All of these

(17) Ternary operator in C programming is ___.


a) if-else-if b)? :
c)? ; ? d) None of these

(18) What will be the output of the following C code?


#include <stdio.h>
int main()
{
printf((43 > 43) ? "value 1 is greater!" : "value 1 is not greater!");
return 0;
}
a) value 1 is not greater b) value 1 is greater
c) Error d) None of these

(19) Which statement is required to execute a block of code when the condition is false?
a) for b) if
c) else d) All of these

(20) What will be the output of the following C code?


#include <stdio.h>
int main(){
int n = 65;
if (n >= 75) {
if (n >= 95) {
printf("Excellent");
}
else
printf("Pass");
}
else
printf("Fail");
}
a) Excellent b) Pass
c) Fail d) None of these

(21) Multiple values of the same variable can be tested using ___.
a) Switch b) for
c) Function d) All of these

(22) Loops in C programming are used to ___.


a) Execute a statement based on a condition b) Execute a block of code repeatedly
c) Create a variable d) None of these

(23) What will happen if the loop condition will never become false?
a) Program will throw an error b) Program will loop infinitely
c) Loop will not run d) None of these

(24) What will be the output of the following C code?


#include <stdio.h>
int main()
{
int a = 11;

while (a < 20)


{
printf("%d ", a);
a += 2;
}
return 0;
}
a) 11 13 15 17 19 b) 11 12 13 14 15 16 17 18 19 20
c) 11 13 15 17 19 21 d) None of these

(25) When the condition of the do-while loop is false, how many times will it execute the
code?
a) 0 b) 1
c) Infinite d) All of these

(26) A string is terminated by ___.


a) Newline ('\n') b) Null ('\0')
c) Whitespace d) None of the above

(27) Which format specifier is used to read and print the string using printf() and scanf()
in C?
a) %c b) %str
c) %p d) %s

(28) Which function is used to concatenate two strings in C?


a) concat() b) cat()
c) stringcat() d) strcat()

(29) What will be the output of the following C code?


#include <stdio.h>
int main()
{
char str1[] = { 'H', 'e', 'l', 'l', 'o' };
char str2[] = "Hello";
printf("%ld,%ld", sizeof(str1), sizeof(str2));
return 0;
}
a) 5,5 b) 6,6
c) 5,6 d) None of the above

(30) Which function is used to compare two strings in C?


a) strcmp() b) strcmpi()
c) compare() d) cmpi()

(31) Which is the correct syntax to declare an array in C?


a) data_type array_name[array_size]; b) data_type array_name{array_size};
c) data_type array_name[]; d) All of the above
(32) Which is/are the correct syntax to initialize an array in C?
a) data_type array_name[array_size] = {value1, value2, value3, …};
b) data_type array_name[] = {value1, value2, value3, …};
c) data_type array_name[array_size] = {};
d) Both A and B

(33) Array elements are always stored in ___ memory locations.


a) Random b) Sequential
c) Both A and B d) None of the above

(34) Let x is an integer array with three elements having value 10, 20, and 30. What will
be the output of the following statement? printf("%u",x);
a) Prints the value of 0th element (i.e., 10)
b) Prints the garbage value
c) An error occurs
d) Print the address of the array (i.e., the address of first (0th) element

(35) Which of the following is the collection of different data types?


a) Structure b) string
c) Array d) All of the above

(36) Which operator is used to access the member of a structure?


a) - b) >
c) * d).

(37) Which of these is a user-defined data type in C?


a) int b) union
c) char d) All of these

(38) What is a function in C?


a) User defined data type b) Block of code which can be reused
c) Declaration syntax d) None of these

(39) Which keyword is used to return values from function?


a) Return b) Value
c) Return type d) All of these

(40) A recursive function in C ___.


a) Call itself again and again b) Loop over a parameter
c) Return multiple values d) None of these

(41) Which of the below syntax is the correct way of declaring a function?
a) return function_name () { } b) data_type function_name (parameter) { }
c) void function_name ( ) d) None of these
(42) Before using a pointer variable, it should be ___.
a) Declared b) Initialized
c) Both A. and B. d) None of the above

(43) A ___ can be assigned the address of any data type.


a) Dangling pointer b) Wild pointer
c) Void pointer d) Null pointer

(44) Which function is used to open a file in C?


a) open() b) fopen()
c) file_open() d) fileopen()

(45) Which is the correct syntax to declare a file pointer in C?


a) File *file_pointer; b) FILE *file_pointer;
c) File file_pointer; d) FILE *file_pointer;

(46) Which function is used to close an opened file in C?


a) close() b) fclose()
c) file_close() d) fileclose()

(47) Function fwrite() works with ___.


a) Text files b) Binary files
c) Both A. and B. d) None of the above

(48) What is the value of EOF in C?


a) -1 b) 0
c) 1 d) Null

(49) Which function checks the end-of-file indicator for the given stream in C?
a) eof() b) EOF
c) feof() d) None of the above

(50) Which function is used to seek the file pointer position in C?


a) seek() b) fseek()
c) fileseek() d) fmove()

(51) Header files ___.


a) Contain function declarations b) Can be included to a program
c) End with .h extension d) All of these

(52) Which of these is not a valid preprocessor in C?


a) \ b)?
c) ### d) None of these
(53) (\) operator in C is ___.
a) Macro continuation operator b) Stringize operator
c) Tokenizer d) None of these

(54) What is CPP in C programming?


a) C processing platform b) C PreProcessor
c) C pre-platform d) None of these

(55) C language is a ___.


a) Procedural oriented programming language
b) General purpose programming language
c) Structured programming
d) All of the above

(56) The C source file is processed by the ___.


a) Interpreter b) Compiler
c) Both Interpreter and Compiler d) Assembler

(57) To develop which operating, C language was invented?


a) Linux b) Unix
c) Android d) Mac

(58) Which are the fundamental data types in C?


a) char b) int
c) float d) all of the above

(59) How many types of qualifiers are there in C language?


a) 2 b) 3
c) 4 d) 5

(60) Which C keyword is used to extend the visibility of variables?


a) Extend b) extends
c) Extern d) auto

You might also like