MCQ Unit 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Matoshri College of Engineering Research Center, Nashik

Basics of C programming

1 All keywords in C are in 7 C progrmming can be used on


A. Lower case letter A. only MS-DOS operating system
B. Upper case letter B. only linux operating system
C. Camel case letter C. only windows operating system
D. Any of above D. All of the above

2 The C language supports 8 Preprocessor Directives are used for -


A. Library function A. Macro Expansion
B. User defined function B. File Inclusion
C. Both A & B C. Conditional Compilation
D. None of the above D. All of these

3 The library functions are made available to 9 C program are converted into the machine
program, by using . language with the help of?
A. #include<libraryname.h> A. An editor
B. #define<libraryname.h> B. Compiler
C. %define<libraryname.h> C. An operating system
D. %include<libraryname.h> D. None of the above

4 Linker generates _____________ file. 10 C is a _____________ language

A. Object code A. High Level


B. Executable code B. Low Level
C. Assembly code C. Middle Level
D. None of the above. D. Machine Level

5 At what stage the contents of header file 11 The prototype of the function in the header
stdio.h get included in the program? file is-
A. During execution A. Stdio.H
B. During compilation B. stdlib.h
C. Before compilation C. conio.h
D. After compilation D. io.h

6 In function default returns a value of type 12 What is C preprocessor?

A. int A. Program that converts source code to object


B. char code
C. void B. Program that converts source code to
D. None of these expanded source code
C. Program that converts source code to
executable code

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

C Operators
1 The equality operator is represented by 7 Which operator has lowest priority?

A. : = A. Assignment
B. /= B. Division
C. = = C. Comma
D. = D. Conditional operator

2 The C language consists of ____number of 8 Which operator gives true only when both the
keyword operand are true.
A. 32 A. !=
B. 40 B. &&
C. 24 C. !
D. 56 D. ||

3 What ill e the alue u after e e utio 9 In mathematics & computer programming,
of following code? int num = 10; num / = which is the correct order of mathematical
num; operators?

A. 2 A. Addition, Subtraction, Multiplication, Division


B. 1 B. Division, Multiplication, Addition, Subtraction
C. 5 C. Multiplication, Addition, Division, Subtraction
D. 0 D. Addition, Division, Modulus, Subtraction

4 Which is not a keyword in C? 10 Witch on of the following allowed in C


arithmatic operation
A. typedef A. ( )
B. const B. { }
C. static C. < >
D. complex D. all of the above

5 If a=3, b=0 & c=-4, what is the value of the 11 The symbol # in #defined statement must be
expression a&&b||c commence from

A. 1 A. The first colum of a line


B. 3 B. anywhere in a line
C. 0 C. The first colum of a last line
D. 4 D. the first line

6 If A=20 and B=10; then the operation A = A*B 12 If A=10 and B=5; then the operation A *= B,
+ B, result is _____. result is _____.
A. 10 A. 1
B. 2 B. 15
C. 400 C. 5
D. 210 D. 50

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

13 which of the following is used to test the 18 Determine which of the following is not
condition allowed in C.
A. A relational operator A. \t
B. A logical operator B. \n
C. A numerical Variable C. \b
D. A numerical constant D. \p

14 If A is an integer variable, A=5/2 will return 19 which is the correct order of the following
value? expression Z=x + y * Z / 4 % 2 - 1
A. 2.5 A. / * % - + =
B. 5 B. .=* / % + -
C. 0 C. * / % + - =
D. 2 D. % * / - + =

15 what are the value of x and y after execution 20 what are the value of x and y after execution
of the following statement of the following
int x, statement
y;
int x, y; x = 2;
x = 2; y = (++x)*10;
y = (x++)*10;
A. x = 2, y = 20
A. x = 2, y = 20 B. x = 3, y = 20
B. x = 3, y = 20 C. x = 3, y = 30
C. x = 3, y = 30 D. None of the above
D. None of the above

16 If A=10 and B=5; then the operation A %= B,


A. result
1 is _____.
B. 2
C. 0
D. None of the above

17 Identify logical operator


A. *
B. !=
C. !
D. None of the above

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Variable Declaration

1 A variable declaration is the assignment of 7 Which of the following is true for variable
A. properties to a variable name in C programming?

B. memory space to a variable They can contain alphanumeric characters as


A.
C. memory space and properties to a variable well as special character.
D. None of these B. Variable names cannot start with a digit.
C. Variable can be with length of 31 character
2 Which is valid C expression? It is not an error to declare a variable to be one
D.
A. int my_num = 100,000; of the keyword
B. int my_num = 100000;
C. int my num = 1000; 8 How will you write write comments in a C
D. int $my_num = 10000; programming
A. /* Statement* /
3 Variable name resolving (number of B. / / Statement / /
significant characters for uniqueness of C. / Statement /
variable) depends on
D. / Statement
A. Compiler and linker implementations
B. Assemblers and loaders implementations
C. C language
D. None

4 Which of the following is not a valid variable


name declaration?
A. int abc3;
B. int a3_bc;
C. int 3abc;
D. int a3bc;

5 Which of the following is not a valid variable


A. name
float PIdeclaration?
= 3.14;
B. double PI = 3.14;
C. int PI = 3.14;
D. #define PI 3.14

6 Which of the following is not a valid C


A. variable name?
int number;
B. float rate;
C. int variable_count;
D. int $main;

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Data type

1 The for at ide tifier % i is also used for 10 Which control string is used to represent long
data type? float data type?
A. char A. %d
B. int B. %lf
C. float C. %e
D. double D. %lu

2 The size of an data type are 11 An unsigned integer variable contains values.

A. 4 Bytes A. Only zero


B. 8 Bytes B. Less than zero
C. Depends on the system/compiler C. Greater than or equal to zero
D. Cannot be determined D. Both (B) & (C)

3 What is short int in C programming? 12 The word 'int' is a

A. Basic data-type of C A. Keyword


B. Qualifier B. Password
short is the qualifier and int is the basic
C. C. Header file
datatype
D. All of the mentioned D. None of these

4 Which data type is most suitable for storing a 13 Which is correct with respect to size of the
number 65000 in a 32-bit system? data types?
A. signed short A. char > int > float
B. unsigned short B. int > char > float
C. long C. char < int < double
D. int D. double > char > int

5 The format specifier '%i" is an another format 14 The default return data type in function
specifier used for which data type? definition is?
A. int A. void
B. float B. int
C. long float C. float
D. none of these D. char

9 Unsigned integer occupies 15 which of the following are data type

A. Two bytes A. unsigned long int


B. Four bytes B. double
C. One bytes C. float
D. Eight bytes D. all of the above

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik
Input Output

1 How many times the following program 6 Which scanf( ) statement will you use?
ould pri t a
printf(“abc”); float a; double b;

A. 469 times A. scanf("%f %f", &a, &b);


B. 1 times B. scanf("%lf % lf ", &a, &b);
C. Infinite times C. scanf("%Lf %Lf", &a, &b);
D. None of the above D. scanf("%f %lf", &a, &b);

2 E e utio of pri tf %d , A ; displa s? 7 The function scanf() returns .........


A. ASCII value of A A. The actual values read for each argument.
B. A B. Number
C. Binary value of A C. Integer
D. None of these D. ASCII value of the input read.

3 What is the output of the program? 8 What are the value of x and y after execution
of the following statement
int i=2; int x,y; x=2; y=(x++)*10;
printf(“%d”, i+=1); printf(“X=%d y=%d”,x,y);

A. 3 A. X=2, y=20
B. 2 B. X=3, y=20
C. 0 C. X=3, y=30
D. -1 D. No value

4 What is the output of the program? 9 Which of the following function needs
x = 5; inclution of conio.h in the header file
y = x++;
printf(“%d %d”, x, y);
A. printf()
A. 5 6 B. scanf()
B. 5 5 C. getch()
C. 6 5 D. all of the above
D. 6 6

5 What will be the output of the program? 10 What is the output of the program?
#include<stdio.h> #include<stdio.h>
void main() void main()
{ {
int a; int a; a=20;
printf(5+"Good Morningn"); printf("%d", a);
} }
A. Good Morning A. 20
B. 5+"Good Morningn B. a
C. 5+"Good C. %d
D. None of these D. none

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Control Statements

1 What will be the output of program? 5 Find out error in the program?
X=1,Y=1,n=0; #include<stdio.h>
if (n>0) void main( )
{ {
X = X+1; if(2 > x)
Y = Y-1; printf(“ABC”);
} printf(“CBA”);
Printf(“%d and %d”,x,y); }
A. 1 and 1 A. No error
B. 1 and 0 B. Data type is not declare
C. 2 and 1 C. Something is missing
D. 2 and 0 D. No output

2 control statement that allowed us to make a 6 What will be the output of program?
decision from number of choice is called?
#include<stdio.h>
A. if- else void main( )
B. for {
C. arrary int X=32,Y=66;
D. do-while if(X<Y)
printf(“%d”, X);
3 What will be the output of the program? }
void main( ) A. 32
{ B. 66
int x = 3; float y = 3.0; C. x
if(x = = y) D. y
printf("x equal y"); else
printf("x not equal to y"); 7 What will be the output of the program?
} void main( )
A. x equal y {
B. x and y are not equal float x = 7.3;
C. Unpredictable if(7.3 > x)
D. No output printf("Hi");
else printf("Hello");
4 Which of the flowing statement are correct
}
about if-else statement?
I. Nested if-else statements are allowed. A. Hi
II. Every if must have an else with it. B. Hello
A. Only I is correct C. Hi Hello
B. Only I is correct D. No output
C. Both I & II is correct
D. Both I & II is correct

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Arrary

1 An array is also called as 7 int a[5] = {1,2,3} What is the value of a[4]?

A. Vector A. 0
B. Pointer B. 2
C. Variable C. 3
D. Cannot say D. Garbage Value

2 What is right way to Initialize array? 8 Which of the following correctly accesses the
seventh element stored in arr, an array with
A. int num[6] = { 2, 4, 12, 5, 45, 5 };
100 elements?
B. int n{} = { 2, 4, 12, 5, 45, 5 };
C. int n{6} = { 2, 4, 12 }; A. arr[6]
D. int n(6) = { 2, 4, 12, 5, 45, 5 }; B. arr[7]
C. arr{6}
3 If m and n are predefined constant in c, which D. None of these
of the following is not valied statement
9 what is the output of the following code.
A. int num[m] int a[7] = {1, 2, 3, 4, 5, 6, 7}
B. int num[n+2] printf(“%d”, a[4]- a[0]);
C. int num[m+n] A. 3
D. None of the above B. 2
C. 1
4 Let x be an array. Which of the following D. 0
operations are illegal?
I. ++x II. X[2]+1 10 what is the output of the following code.
III. x++ I V. x*2 int a[2][3]={ 1, 2, 3, 4 ,5, 6}
A. I and II printf %d ,& a[ ][ ] ;
B. I, II and III A. 1 2 3 4 5 6
C. II and III B. 6
D. I, III and IV C. 2
D. 9
5 Array passed as an argument to a function is
interpreted
A. Address as array.
of the 11 What will be the output of the program ?
B. Values of the first elements of the array. int a[5] = {5, 1, 15, 20, 25};
C. Address of the first element of the array. int i, j;
D. Number of element of the array. i = ++a[1];
j = a[1]++;
6 An array elements are always stored in printf("%d, %d", i, j);
A. Sequential A. 3, 2
B. Random B. 2, 3
C. Sequential and Random C. 2, 1
D. None of the above D. 1, 2

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Function
1 The name of all functions end with a 6 The argument in function definition is

A. pair of parenthesis A. Actual


B. semicolon B. Formal
C. braces C. Globle
D. None D. any of the above

2 Which of the following is a correct format for 7 Which of the following is a correct format for
definition of function? declaration of function?
A. return-type function-name(argument type); A. return_type function_name(argument type);
B. return-type fun-name(argument type) { } B. return_type function_name(argument type) {}
C. return-type (argument type)function-name; C. return_type function_name(argument type);
D. Both (a) and (b) D. Both (a) and (b)

3 What is function? 8 While declarating the function


A. Function is a block of statements that perform A. A function with same name cannot have
some specific task. different signatures
B. Function is the fundamental modular unit. A B. A function with same name cannot have
function is usually designed to perform a different return types
specific task.
C. C. A function with same name cannot have
Function is a block of code that performs a
different number of parameters
specific task. It has a name and it is reusable.
D. All of the above D. All of the above

4 The default parameter passing mechanism is 9 How many arguments function can recives

A. call by value A. 0
B. call by reference B. 1
C. call by value result C. 2
D. None of these. D. many

5 When we mention the prototype of a 10 What is the default return type if it is not
function? specified in function definition?
A. Defining A. void
B. Declaring B. int
C. Prototyping C. double
D. Calling D. short int

11 Call by reference is also known as ? 11 A 'return' statement is used _______.


A. Call by address or Call by location A. to exit from program
B. Call by address or Call by value B. to return the value from a function
C. Call by value or Call by name C. to terminate the iterative loop
D. None of above D. all of the above

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

12 With respect to user defined function, what is


true about the statement on number 1, 5, and
8 respectively?
1. float abc(int x);
2. void main( )
3. {
4. int i=5,y;
5. y=abc(i);
6. Printf %d ,y ;
7. }
8. float abc(int x);
9. {return(x*x);}
A. function definition, calling and declaration
B. function declaration, calling and definition
C. function definition, and declaration calling
D. None of the above

13 Which of the following is a incorrect?


Retun statement is optional in function
A.
defition
B. Retun statement can return garbage value
C. two function can have same name
D. a function can recive any number of argument

14 the keyword 'void' in function declaration


indicates _____________.
A. the fuction will return 'int' type of value.
B. the fuction will return 'default' type of value.
C. the fuction will not return any value.
D. the fuction will return 'empty' value.

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik

Loop Statements

1 Differe e et ee hile a d do- hile 6 In for loop, for (exp1; exp2; exp3). What is
loop? mean by exp1, exp2, exp3?

While loop executes one or more times and do-


A. A. Initialization; Condition; Incre/decrement
while executes zero or more times.
Both while and do-while loop executes one or
B. B. Initialization; Incre/decrement; Condition;
more times.
Both while and do-while loop executes zero or
C. C. Incre/decrement; Initialization; Condition;
more times.
While loop executes zero or more times and
D. D. None of the above
do-while executes one or more times.

2 What will be the output of the program? 7 What is mean by exp1, exp2, exp3 in while
int i=0; loop?
exp1;
for(i=1; i<5; i++) while(exp2)
{ {
printf("\t%d", i); statements; exp3;
} }
A. 1 2 3 4 A. Initialization; Incre/decrement; Condition;
B. 0 1 2 3 4 5 B. Incre/decrement; Initialization; Condition;
C. 1 2 3 4 5 C. Initialization; Condition; Incre/decrement
D. None of the above D. None of the above

3 How long the following loop runs? 8 How long the following loop runs?
for(x=1;x=3;x++) for(x=10;x<10;x--)
A. 3 times A. 3 times
B. 2 times B. 2 times
C. 1 times C. 1 times
D. 0 times D. 9 times

4 Which of the following is not an entry 9 Which the loop statements within the loop
controlled loop? are executed at least once?
A. While loop A. do-while
B. For loop B. while
C. Do-while loop C. for
D. All of the above D. goto

5 The minimum number of times the do-while 10 Which the loop statements within the loop
loop executed is? are executed at least zero?
A. 0 A. do-while
B. 1 B. while
C. 2 C. for
D. Cannot be predicted D. goto

Numerical Methods Computer Programming


Matoshri College of Engineering Research Center, Nashik
11 How long the following loop runs?
int j = 1;
while(j <= 300)
{
printf("%d", j);
j++;
}
A. Infinite times
B. 300 times
C. 5 times
D. 299 times

12 What will be the output of program?


int i=1,sum=0;
do
{
sum+=i; i=i+2;
}(while i<=5)
printf(“%d\t%d”, i, sum);
A. 7 9
B. 4 3
C. 2 1
D. 4 6

13 Which of the following 'for' loop sets up an


infinite loop
A. one which has no initialization expression.
B. one which has no looping condition.
C. one which has more the one looping condition.
D. All of the Above

Numerical Methods Computer Programming

You might also like