NEW
Font size
WorksheetsSec-I-cquiz1
Total questions: 77
Worksheet time: 37mins
Which header file is required to perform standard input and output opeartions
math.h
stdio.h
input.h
io.h
Which of the following is correct identifier?
int
1ab
a_123
a 123
what is the output of the following statement?
printf("hi\nhello\nhow\bare\ryou");
hi
hello
how
are
you
hi
hello
hoare
you
hi
hello
youre
hi
hello
youare
Who is the father of C language?
Dennis Ritche
Charles Babbage
Steve Jobs
V Kohli
Which of the following is not a valid C variable name?
int num;
float price;
char a_s;
int $total;
The C-preprocessors are specified with _________ symbol.
$
#
&
*
What is the sizeof(char) in a 32-bit C compiler?
1 bit
2 bits
1 byte
2 bytes
What will be the final value of x in the following C code?
#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}
3.75
24
3
15
What will be the output of the following C code snippet?
#include <stdio.h>
void main()
{
1 < 2 ? printf("Hi"): printf("hello");
}
Hi
hello
hi
hello
none
What is the size of an int data type in 64-bit compiler?
4 bytes
8 bytes
10 bytes
2 bytes
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int y = 3;
int x = 5 % 2 * 3 / 2;
printf("Value of x is %d", x);
}
Value of x is 1
Value of x is 3
Value of x is 1.5
Error
What is the precedence of arithmetic operators (from highest to lowest)?
%, *, /, +, –
%, +, /, *, –
+, -, %, *, /
%, +, -, *, /
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf("%d", c);
}
15.6
15
16
10
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
Error
1
10
15
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = (x && y) || (z++);
printf("%d", z);
}
error
5
6
0
Which among the following is NOT a logical opearator?
&&
||
!
!=
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}
error
1
8
-1
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int h = 8;
int b = h++;
printf("%d%d\n", b, h);
}
8 8
8 9
9 9
9 8
What will be the output of the following C code?
#include <stdio.h>
void main()
{
char b = 'B';
printf("%d\n", b);
}
65
66
B
b
What will be the output of the following C code?
#include <stdio.h>
void main()
{
char b = 'B';
printf("%c\n", b+32);
}
65
66
B
b
The ______ symbol denotes decision making in flowchart?
What will be the output of the following C code?
#include <stdio.h>
void main()
{
char b = 'B';
printf("%c\n", b+3);
}
E
e
B
b
The ______ symbol used for input/ output operation in flowchart?
What is the output of this program?
#include <stdio.h>
void main()
{
printf("hello\rworld\n");
printf("hello\b\b\bworld\n");
}
hello
helloworld
world
heworld
world
hellworld
helloworld
heworld
What is the output of the following code?
void main()
{
int i=1;
i=2+2*i++;
printf("%d",i);
}
2
3
4
5
What is the output of this program?
main ()
{
int i=5;
printf( "%d %d %d " , i, i<<2, i>>2);
}
5 1 20
5 20 1
5 20 20
5 1 1
C- has ______ Keywords
28
32
4
12
What compiler does?
converts HL code into LL code and doesn't save
converts LL code into HL code and saves
converts HL code into HL code and saves
converts HL code into LL code and saves
1 byte =
6 bits
8 bits
10 bits
12 bits
What is INTEL stands for in the company name intel?
Intermediate Electronics
Intelligent Electronics
Integrated Electronics
Industrial Electronics
Conditions are developed using......
Arithmetic Operators
Logical Operators
Comparision Operators
Assignment Operator
what will be output of ....
printf("%d",10+5/2);
7.5
7
12
12.5
what will be output of....
printf(" %d ", 5.6 / 2.3);
2.5
2.2
2.8
0
the % (modulus) can be used with _____ data type
double
float
int
char
logical operators are used for......
developing conditions
combining conditions
using conditions
none of the above
what will be output of following code?
int a=25;
int b=a / 10 % 10;
printf("%d",b);
25
5
2
20
what wil be output of .....
a=5; b=10;
a=a+b;
b=a-b;
a=a-b;
printf("a=%d b=%d",a,b);
a=5 b=10;
a=10 b=10
a=5 b=5
a=10 b=5
what will be output of....
a=5; //line 2
6=b; //line 3
printf("sum is %d",a+b); //line 4
sum is 11
error at line 2
error at line 3
error at line 4
What is full form of ASCII?
American Suitable Code for Information Interchange
American Standard code for Interactive Information
American Standard code for Information Interaction
None of the above
the ascii range is .....
-32768 to 32767
-128 to 128
0-327
-128 to 127
what will be output of following code:
int a;
printf("%d",&a);
display garbage value
display address of a
display 5
none of the above
what will be output of ....
int a=32765;
printf("%d",a+5);
32770
-32768
-32766
32766
printf("%d",08);will display....
8
08
10
error
if(a>b)
printf("hi");
else;
printf("hello");
if given input is 15 & 10 what will be output?
hi
hello
hi hello
ERROR
if(a>b);
printf("a is big");
else
printf(" b is big");
if input is 5 & 10 what is output?
5
10
5 10
error
Which is called a conditional operator in C?
>
==
? :
NONE
what is main()?
its a function call
user defined function
pre defined function
library function
WHT WILL BE OUTPUT OF ...
printf("%c", 'A'+7);
h
A
H
Error
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int ch = 2;
switch(ch) {
case 1: printf("1 ");
case 2: printf("2 ");
case 3: printf("3 ");
default: printf("None");
}
}
int main() {
solve();
return 0;
}
1 2 3 None
2
2 3 None
None
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int x = 1, y = 2;
printf(x > y ? "Greater" : x == y ? "Equal" : "Lesser");
}
int main() {
solve();
return 0;
}
Greater
Lesser
Equal
None of the above.
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
printf("%d ", 9 / 2);
printf("%f", 9.0 / 2);
}
int main() {
solve();
return 0;
}
4 4.5000
4 4.000
4.5000 4.5000
4 4
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int x = 2;
printf("%d", (x << 1) + (x >> 1));
}
int main() {
solve();
return 0;
}
5
4
2
1
In which of the following languages is function overloading not possible?
C
C++
Java
Python
Which of the following function is used to open a file in C++?
fopen
fclose
fseek
fgets
Which of the following are correct file opening modes in C?
r
rb
w
All of the above.
What is the return type of the fopen() function in C?
Pointer to a FILE object.
Pointer to an integer.
An integer.
An integer.
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int ch = 2;
switch(ch) {
case 1: printf("1 ");
case 2: printf("2 ");
case 3: printf("3 ");
default: printf("None");
}
}
int main() {
solve();
return 0;
}
1 2 3 None
2
2 3 None
None
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int x = 1, y = 2;
printf(x > y ? "Greater" : x == y ? "Equal" : "Lesser");
}
int main() {
solve();
return 0;
}
Greater
Lesser
Equal
None of the above.
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int n = 24;
int l = 0, r = 100, ans = n;
while(l <= r) {
int mid = (l + r) / 2;
if(mid * mid <= n) {
ans = mid;
l = mid + 1;
}
else {
r = mid - 1;
}
}
printf("%d", ans);
}
int main() {
solve();
return 0;
}
5
4
3
6
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
printf("%d ", 9 / 2);
printf("%f", 9.0 / 2);
}
int main() {
solve();
return 0;
}
4 4.5000
4 4.000
4.5000 4.5000
4 4
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int x = 2;
printf("%d", (x << 1) + (x >> 1));
}
int main() {
solve();
return 0;
}
5
4
2
1
What will be the output of the following code snippet?
#include <stdio.h>
#define VAL 5
int getInput() {
return VAL;
}
void solve() {
const int x = getInput();
printf("%d", x);
}
int main() {
solve();
return 0;
}
5
Garbage Value
Compilation Error
0
How to find the length of an array in C?
sizeof(a)
sizeof(a[0])
sizeof(a) / sizeof(a[0])
sizeof(a) * sizeof(a[0])
Which of the following is not a storage class specifier in C?
volatile
extern
typedef
static
What will be the output of the following code snippet?
#include <stdio.h>
void solve(int x) {
if(x == 0) {
printf("%d ", x);
return;
}
printf("%d ", x);
solve(x - 1);
printf("%d ", x);
}
int main() {
solve(3);
return 0;
}
3 2 1 0 1 2 3
3 2 1 0
0 1 2 3
None of the above
What will be the output of the following code snippet?
#include <stdio.h>
int search(int l, int r, int target, int a[]) {
int mid = (l + r) / 2;
if(a[mid] == target) {
return mid;
}
else if(a[mid] < target) {
return search(mid + 1, r, target, a);
}
else {
return search(0, mid - 1, target, a);
}
}
void solve() {
int a[] = {1, 2, 3, 4, 5};
printf("%d", search(0, 5, 3, a));
}
int main() {
solve();
return 0;
}
2
3
4
5
What will be the output of the following code snippet?
#include <stdio.h>
int get(int n) {
if(n <= 1) {
return n;
}
return get(n - 1) + get(n - 2);
}
void solve() {
int ans = get(6);
printf("%d", ans);
}
int main() {
solve();
return 0;
}
5
1
0
8
What is the output of the following code snippet?
#include <stdio.h>
#include<stdlib.h>
void set(int *to) {
to = (int*)malloc(5 * sizeof(int));
}
void solve() {
int *ptr;
set(ptr);
*ptr = 10;
printf("%d", *ptr);
}
int main() {
solve();
return 0;
}
10
Garbage Value
Cannot Say
The program may crash.
Which of the following will occur if we call the free() function on a NULL pointer?
Compilation Error.
Runtime Error.
Undefined Behaviour.
The program will execute normally.
Which of the following should be used to free memory from a pointer allocated using the “new” operator?
free()
delete
realloc()
None of the above.
Which data structure is used to handle recursion in C?
Stack.
Queue.
Deque.
Trees.
What will be the output of the following code snippet?
#include <stdio.h>
#define CUBE(x) x x x
void solve() {
int ans = 216 / CUBE(3);
printf("%d", ans);
}
int main() {
solve();
return 0;
}
8
648
72
None of the above.
What will be the output of the following code snippet?
#include <stdio.h>
struct School {
int age, rollNo;
};
void solve() {
struct School sc;
sc.age = 19;
sc.rollNo = 82;
printf("%d %d", sc.age, sc.rollNo);
}
int main() {
solve();
return 0;
}
19 82
Compilation Error
82 19
None of the above.
Which of the following is not true about structs in C?
No Data Hiding.
Functions are allowed inside structs.
Constructors are not allowed inside structs.
Cannot have static members in the struct body.
What will be the output of the following code snippet?
#include <stdio.h>
struct School {
int age, rollNo;
};
void solve() {
struct School sc;
sc.age = 19;
sc.rollNo = 82;
printf("%d", (int)sizeof(sc));
}
int main() {
solve();
return 0;
}
1
4
8
16
What will be the output of the following code snippet?
#include <stdio.h>
union School {
int age, rollNo;
double marks;
};
void solve() {
union School sc;
sc.age = 19;
sc.rollNo = 82;
sc.marks = 19.04;
printf("%d", (int)sizeof(sc));
}
int main() {
solve();
return 0;
}
4
8
16
12
What will be the output of the following code snippet?
#include <stdio.h>
#include<string.h>
void solve() {
char s[] = "Hello";
printf("%s ", s);
char t[40];
strcpy(t, s);
printf("%s", t);
}
int main() {
solve();
return 0;
}
Hello Hello
Hello
Compilation Error
None of the above.
