Font size
WorksheetsC Unit 1
Total questions: 100
Worksheet time: 50mins
Which of the following is not a valid variable name declaration?
int a3;
int 3a;
int _A3;
int a_3
All keywords in C are in ____________
Lowercase
Uppercase
Camelcase
None of these
A translator which reads an entire program written in a high level language and converts it into machine language code is:
Assembler
Compiler
Linker
Loader
Which is correct with respect to size of the data types?
char > int > float
int > char > float
char < int < double
double > char > int
Which is valid C variable declarations?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
The functions printf() and scanf() are defined in which of the following library file:-
math.h
conio.h
stdio.h
stdlib.h
#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
128
0
-128
Garbage Value
#include <stdio.h>
void main()
{
int k = 4;
float k = 4;
printf("%d", k)
}
A.
4
4.000000
No output
Compile time Error
Who developed C language
Dennis Ritchie
Bill Gates
Dennis Lilly
Stephen
Which is variable declaration?
int a,b;
c=a+b;
printf("%d%d",a,b)
scanf("%d%d",&a,&b);
how to print a and b variable of int and float respectively
scanf("%d%f",&a,&b);
printf("%d%f",a,b);
printf("%f%d",&a,&b);
printf("%f%d",&a,&b);
Choose all the correct statements in reference to the programming language C
General purpose programming language
Middle level programming language
Structured programming language
Object oriented programming language
Library function pow() belongs to which header file?
mathio.h
math.h
square.h
stdio.h
Libray function getch() belongs to which header file?
stdio.h
conio.h
stdlib.h
stdlibio.h
A name having a few letters, numbers and special character _(underscore) is called
keywords
reserved keywords
tokens
identifiers
What will be the output of the C code?
Hello World! x;
Hello World! followed by a junk value
Compile time error
Hello World!
Is it possible to run program without main() function?
yes
no
-
-
Which of the following is not a correct variable type?
float
real
int
char
Evaluate(to true or false) each of the following expressions:
(1) 14 <= 14
(2) 14 < 14
false false
true true
true false
false true
Which of the following is the boolean operator for logical-AND?
&
&&
|
||
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of the above
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}
while(a <= 30);
return 0;
}
32
33
30
No Output
Choose a correct C Statement.
a++ is (a=a+1) POST INCREMENT Operator
a-- is (a=a-1) POST DECREMENT Operator
--a is (a=a-1) PRE DECREMENT Operator
++a is (a=a+1) PRE INCREMENT Operator
All the above.
Choose correct Syntax for C Arithmetic Compound Assignment Operators.
a+=b is (a= a+ b)
a-=b is (a= a-b)
a*=b is (a=a*b)
a/=b is (a = a/b)
a%=b is (a=a%b)
All the above.
In the following loop construct, which one is executed only once always.
for(exp1; exp2; exp3)
exp1
exp3
exp1 and exp3
exp1,exp2 and exp3
The continue statment cannot be used with
for
while
do while
switch
int main()
{
int a = 10, b = 25;
a = b++ + a++;
b = ++b + ++a;
printf("%d %d n", a, b);
}
36 64
35 62
36 63
30 28
#include<stdio.h>
int main()
{
float a=0.7;
if(a<0.7)
{
printf("C");
}
else
{
printf("C++");
}
}
C
C++
Compilation Error
None of the these
int main() {
int m = -10, n = 20;
n = (m < 0) ? 0 : 1;
printf("%d %d", m, n);
}
-10 0
10 20
20 -10
0 1
#include<stdio.h>
int main()
{
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
}
0
7
2
Compilation error
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of the above
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}
while(1);
return 0;
}
No Output
32 33 34
32 33 34 35
Compiler error
What is the output of C Program.?
int main()
{
int k;
for(;;)
{
printf("TESTING\n");
break;
}
return 0;
}
No Output
TESTING
Compiler error
None of the above
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
break; statement
leave; statement
quit; statement
Choose correct C while loop syntax.
while(condition) { //statements }
{ //statements }while(condition)
while(condition); { //statements }
while() { if(condition) { //statements } }
What is the output of C Program.?
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT is printed unlimited number of times
RABBIT
Compiler error
None of the above.
What is the output of C Program.?
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed unlimited number of times.
Compiler error.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("In while loop\n");
} while (i < 3);
}
In while loop
In while loop
In while loop
In while loop
In while loop
Depends on the compiler
Compile time error
1.Relational
2.Arithmetic
3.Logical
4.Assignment
Every C Program Statement must be terminated with a
.
#
;
!
What does the following code fragment write to the monitor?
Under
Over
Under the limit
Over the limit
When applied to a variable, what does the unary "&" operator yield?
The variable's address
The variable's right value
The variable's binary form
The variable's value
The operator "&" is used for
Bitwise AND
Bitwise OR
Logical AND
Logical OR
The size of a character variable in C is
8 bytes
4 bytes
2 bytes
1 byte
The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.
These words are called
keywords
identifier
data types
constant
Which operators are used to compare the values of operands to produce logical value in C language
Logical operator
Relational operator
Assignment operator
None of the above
An opertor used to check a condition and select a value depending on the value of the condition is called
Logical operator
Decrement operator
Conditional or Ternary operator
Bitwise operator
Which operators perform operations on data in binary level?
Logical operator
Bitwise operator
Additional opertors
None of the above
What is the value of this expression using integer arithmetic:
7 / 4
1
2
1.75
Determine the value of this expression using integer arithmetic:
5 % 7
0
2
5
Determine the value of b in this code fragment:
int a=3, b;
b=++a;
3
4
2
Determine the value of the expression using integer arithmetic:
6 * 9 % 3 / 2
2
0
18
Determine the value of a in the second line of the code fragment:
int a=1, b=2;
a=b--;
1
0
2
Which line of code is correct for the statement:
Read in a value for the integer variable num.
printf("%d", &num);
scanf("%d", num);
scanf("%d", &num);
What is the EXACT output from this code fragment:
int num=10;
if(num> 7 % 3 / 2 * 3)
printf("This is True");
else
printf("This is False");
This is True
This is False
Find the output in following code
int main ()
{
int a,b ;
a= b= 4 ;
b =a++;
Printf ( " %d %d %d %d", a++, --b, ++a, b--);
}
5 3 73
5 4 5 3
6 2 6 4
Syntax Error
Find error/ output in following code
int main ()
{
Static int num = 8;
printf ( " %d" , num = num -2 );
if (num != 0)
main ();
}
8 6 4 2
Infinite output
Invalid because main function can't call it self
6 4 2 0
Find error/ output in following code
How many times " placement Questions" will print.
int main
{
int x;
for ( x=1;x <=10; x++)
{
if ( x < 5)
Continue;
else
break;
Printf (" placement Question ");
{
return 0;
}
Infinite time
11 times
0 time
10 times
Find error/ output in following code
int main ()
{
int a = 10, b = 25;
a = b++ + a++;
b= ++b + ++a;
printf ( " %d %d n", a, b );
}
36 64
35 62
36 63
30 28
Find error/ output in following code
Void fn ()
{
Static int i= 10;
Printf ( " %d " , ++i );
}
int main ()
{
fn();
fn();
}
10 10
11 12
11 11
12 12
Find error/output in following code
int main ()
{
int m = -10,n =20;
n = ( m < 0) ? 0 : 1;
printf ( " %d %d ", m,n ) ;
}
-10 0
10 20
20 -10
0 1
Find error/ output in following code
int main ()
{
int i = 0;
for ( ; ;)
printf ( "%d", i) ;
return 0;
}
O times
Infinite times
10 times
1 times
How many main() function we can have in a program
1
2
No Limit
None
How many loop are there in C
2
3
1
4
which of the following ways can be used to include header file in C program
#include"stdio.h"
#include<stdio.h>
both
none
what are the basic data types in C Language
int , float
int , float , char
int, float, char , double
int, char, double
Arithmetic operators available in C Language are
+ , -, *, / , %
+ , -, *, / , <
+ , -, *, ==, <=
&&, ||, ==, >=
Conditional statements are
Simple if , if-else , else-if, switch
Simple if , if-else , else-if, while
Simple if , do-while , else-if, switch
Simple if , if-else , do-while , for
Program execution starts from
#include
main()
Other sub-functions
None
Conditional operator (? :) is a
Unary Operator
Binary Operator
Ternary Operator
All
Examples for Unary operators
% , /
==, &&
<= , >=
++ , --
What is output for:
a=5;
printf("%d", a++) ;
5
6
4
0
What is the output:
int i;
printf("%d", i);
0
Garbage value
1
Error
What is the Output:
int a=5,b=6,c=2;
printf("%d", a+b*c);
17
22
11
Error
What is the Output :
void main()
{
int a=5,b=6,k;
k=b>a?b:a;
printf("%d",k);
}
5
6
11
Error
What is the Output:
void main()
{
int a=4, b=2,c;
c=a*b;
printf("%d%d%d",b,c,a);
}
4, 2, 8
2, 4, 8
4, 8, 2
2, 8, 4
what is the Output:
void main()
{
int a=3,b=6;
if(a>b)
printf("%d",a);
else
printf("%d",b);
}
3
6
Compilation Error
Run Time Error
"goto" statement is:
Conditional statement
Assignment statement
Declaration statement
Unconditional statement
What is the output of C Program.?
int main()
{
while(true)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT
RABBIT is printed unlimited number of times.
No output
Compiler error.
Correct printf statement to print “Hello world”
printf("Hello world);
print("Hello World");
printf(Hello world");
printf("Hello World");
how to Read value from the user into the variable a of type int.
scanf("Read value",&a)
scanf("%d,a");
scanf("%d",&a);
scanf("%d",a);
Which one is not a correct identifier name
num1
num_1
_num1
num 1
How to read multiple values from user for the integer variables a,b and c in a single line?
scanf("%d %d %d",a,b,c);
scanf("%d %d %d,a,b,c);
scanf("%d %d %d",&a,&b,&c");
scanf("%d %d %d",&a,&b,&c);
which is correct to define constants in c program
const int 3.14
const pi-3.14
#define int PI 3.14
const float PI=3.14
A block of comments begin and ends with
starting with / and ending with //
starting with /* and ending with */
starting with // and ending with //
staring with < and ending with >
For assignment statement
Left value should be a variable always
right value can be constant, variable, an expression or combination of this
the assignment is always take place from right to left and never the other way
all of above
Which of the following is not a valid expression in c
a=2+(b=5);
a=b=c=5;
a=11%3
b+5=3;
Which operator has the lowest priority
++
||
+
%
Which of the following is not a valid relational operator
==
=>
<=
>=
which statement uses valid escape sequence:
printf(“Enter two numbers”/n)
printf(“Enter two numbers”\n);
printf(“Enter two numbers/n”);
printf(“Enter Two number\n”);
x<<7 means
x is assigned value 7
x is shifted to right by 7 bytes
x is shifted to left by 7 bits
x is shifted to right by 7 bits
Which is incorrect?
rem=3%2
rem=3.14%2.
rem=’a’%’c’
none of the above
what is result of 16>>2
1
8
2
4
int a=29, b=10;
float c;
c=(float)(a/b)
2.9
2
3
compile dependent
which is the valid variable declaration
int temp salary;
float marks_student;
float roll-no;
int main;
