Font size
WorksheetsProgramming in C Week 1-5(All C topics)
Total questions: 102
Worksheet time: 4hrs 35mins
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=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
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
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.
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 } }
Choose a correct C for loop syntax.
for(initalization; condition; incrementoperation) { //statements }
for(declaration; condition; incrementoperation) { //statements }
for(declaration; incrementoperation; condition) { //statements }
for(initalization; condition; incrementoperation;) { //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 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
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 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
Relational operator
+
=
==
/
a=2;b=6; (a<b):10:15
10
15
2
6
After first pass the answer for x=5-6/3+8*2-1
5-2+8*2-1
5-6/3+16-1
5-2+16-1
-1/3+8*2-1
%s indicates in scanf statement
to get an integer
to get a character
to get a string
to get a real no.
What is the data type use for whole number?
%ld
%f
%lf
What operator that will be perform last in a given equation?
+
/
%
What format specifier is use for double data type?
%lf
%d
%f
Which should be the printf statement of the following program:
void main()
{
int age = 10;
printf...
}
printf("I am %d years old.\n");
printf("I am %f years old.\n", age);
printf("I am %s years old.\n");
printf("I am %d years old.\n", age);
Check the following code segment and try to predict what's going to happen?
#include <stdio.h>
int main(){
int x=++2;
printf("%d",x);
return 0;
}
3 will be printed on compilation and execution.
2 will be printed on compilation and execution.
compilation error - "Ivalue required".
runtime error.
Libray function getch() belongs to which header file?
stdio.h
conio.h
stdlib.h
stdlibio.h
What is the value of X in the sample code given below?
X = ( 2 + 3) * 2 + 3;
10
13
25
28
What value will be stored in z if the following code is executed?
x = 5 , y = -10, a = 4, b = 2;
z = x+++++y * b/a;
-2
0
1
2
#include <stdio.h>
int main()
{
int x = 2, y = 2;
x /= x / y;
printf(“%d\n”, x);
return 0;
}
a) 2
b) 0.5
c) 1
d) Undefined behaviour shown
#include <stdio.h>
int main()
{
int x = 2, y = 1;
x *= x + y;
printf("%d\n", x);
return 0;
}
a) 6
b)5
c) Undefined behavior shown
d) Compilation time error
#include<stdio.h>
void main()
{
int a=5;
int b=6;
a++;
b++;
printf("%d %d",a,b);
}
5 6
6 7
5 7
Compilation Error
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("SKCT");
}
return 0;
}
A.Infinite times
B. 11 times
C. 0 times
D.10 times
#include<stdio.h>
int main()
{
int i=0;
for(; i<=5; i++);
printf("%d", i);
return 0;
}
Compilation Error
6
012345
12345
#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}
A.Hi
B. Hello
C. Hi Hello
D.None of above
#include<stdio.h>
int main()
{
int k, num = 30;
k = (num < 10) ? 100 : 200;
printf("%d\n", num);
return 0;
}
A.200
B. 30
C. 100
D.500
#include<stdio.h>
int main()
{
int a = 300, b, c;
if(a >= 400)
b = 300;
c = 200;
printf("%d, %d, %d\n", a, b, c);
return 0;
}
A.300, 300, 200
B. Garbage, 300, 200
C. 300, Garbage, 200
D.300, 300, Garbage
#include<stdio.h>
int main()
{
char j=1;
while(j < 5)
{
printf("%d, ", j);
j = j+1;
}
printf("\n");
return 0;
}
1 2 3 ... 127
1 2 3 ... 255
1 2 3 ... 127 128 0 1 2 3 ... infinite times
1, 2, 3, 4
The modulus operator cannot be used with a long double.
True
False
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 k, j;
for(k=1, j=10; k <= 5; k++)
{
printf("%d ", (k+j));
}
return 0;
}
compiler error
10 10 10 10 10
10 11 12 13 14 15
None of the above
What is the output of C Program.?
int main()
{
int k;
for(k=1; k <= 5; k++);
{
printf("%d ", k);
}
return 0;
}
1 2 3 4 5
1 2 3 4
6
5
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
int main()
{
char arr[7]="Network";
printf("%s", arr);
return 0;
}
Network
N
Garbage Value
Compilation error
#include<stdio.h>
int main()
{
char arr[11]="The African Queen";
printf("%s",arr);
}
The African Queen
The
The African
Compilation error
int main ()
{
int x = 24, y = 39, z = 45;
z = x + y;
y = z - y;
x = z - y;
printf ("n%d %d %d", x, y, z);
}
24 39 63
39 24 63
24 39 45
39 24 45
int main()
{
int a = 1, b=2, c=3;
char d = 0;
if(a,b,c,d)
{
printf("EXAM");
}
}
No Output and No Error
EXAM
Run time error
Compile time error
What will be output of the following c program?
#include<stdio.h>
int main()
{
int max-val=100;
int min-val=10;
int avg-val;
avg-val = max-val + min-val / 2;
printf("%d",avg-val);
}
55
105
60
Compilation error
Diamond shaped symbol is used in flowcharts to show the-
decision box
statement box
error box
if-statement box
Which of the following is not a valid variable name declaration?
int a3;
int 3a;
int _A3;
int a_3
#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
128
0
-128
Garbage Value
What is the output of following program?
20
30
Compile Error
Runtime Error
Arrays always occupy contiguous memory area
True
False
Which of the following format specifier in printf is used to print pointers?
%c
%d
%f
%p
A pointer is
A keyword used to create variables
A variable that stores address of an instruction
A variable that stores address of a varaibe
All of the above
What is the & in pointers?
Dereferences the memory address into an object
References an object into a memory address
Makes a new copy of the object as a memory address
None of the above.
How do you make a pointer point to an existing variable?
int y = 0;
int *x = y;
int x = y;
int *x = &y;
int &x = *y;
#include <stdio.h> double i; int main() { printf("%g\n",i); return 0; }
0
0.000000
Garbage value
Depends on the compiler
Which operator connects the structure name to its member name?
–
<-
.
Both <- and .
Which of the following cannot be a structure member?
Another structure
Function
Array
None of the mentioned
Computer memory locations are
Bi linear
Linear
Non Linear
Computer address values in reality are in
Decimal
Binary
Hexadecimal
C code
printf("%d", &C), prints
value of C
Address of C
Error message
None of the above
If 5 is added to the address value 'A' of an integer variable the new address is
A +5
A+ 10
A+ 20
Data insufficient
In a C Program if
int a = 5;
Int *ptr = &a;
then the printf statement with
&a, a, *ptr , ptr
adrress, Value, Value, Adress
address, value, value, value
all address
All values
In a C Program if
int a = 5;
Int *ptr = &a;
printf ("%d" , ptr)
gives
5
address of a
address of ptr
none
A double pointer points
address of an integer
address of a pointer
value stored in the memory
None
In a C program,
int a = 20;
*ptr = &a;
**dptr = &ptr;
printf ("%d", **dptr);
prints
address of a
address of ptr
value of a
address of dptr
Which of the following pointer is Wild
int *p;
int *q=&a;
int *v=NULL;
void *g;
What is the main drawback of pointers
Complexity to mange pointers
Difficult to write program
They are not safe
What is the output of the following Code:
#include <stdio.h>
int main()
{
int *p;
int a=10;
p=&a;
*p=34;
printf("%d,%d",a,*p);
return 0;
}
34,34
10,10
10,34
34,10
What is the output of the following code:
#include <stdio.h>
int main()
{
void *z;
float s=1.2;
z=&s;
printf("%f",*z);
return 0;
}
Compile time error
1.20000
1.2
Run time error
What is the output of the following code snippet:
int a=45,b=67;
int *s,*q;
s=&a;q=&b;
printf("%d",s+q);
Compile time error
112
Garbage value
0
Which of the following operators are not used with pointers
*
/
%
-
What is the output of the following code:
int a[]={1,2,33,4,4,6}
int *p;
p=a;
*(p+2)=25;
printf("%d,%d",*(p+2),2[a]);
25,25
25,4
25, garbage value
Compile time error
Which of the following pointers leads to memory leaks
Wild Pointers
Dangling Pointers
NULL Pointers
Generic Pionters
Which of the following is related to pointer to an array concept in C
int a[]={1,2,2,22};
int *p;
p=a;
int (*p)[3];
int a[]={1,2,3};
p=&a;
int *p[3];
int a[]={1,2,2};
p=a;
int **a[];
What is the output of the following code snippet:
char s[]="Ruler";
char p[]="Simha";
strcat(p,s);
printf("%s,%s",p,s);
SimhaRuler,Ruler
Simha,Ruler
RulerSimha,Ruler
Ruler,Simha
What is the output of the following code snippet:
char s[]="Syeraa";
char p[]="NarasimhaReddy";
printf("%d",strcmp(p,s));
5
-5
Not Equal
6
In C language Strings are _______________
Mutable
Immutable
Both Mutable and Immutable
No Mutable and immutable concept in C
What is the output of the following code snippet:
char s[]="Mari-2";
printf("%s",strupr(s));
MARI-2
mari-2
MARI**
Invalid string
What is the output of the following code snippet:
char s[]="Saaho";
printf("%d,%d",strlen(s),sizeof(s));
5,5
6,6
5,6
5,1
What is the answer for the following code:
int a=20;
printf("%p",a);
0014
14
32
20
Which of the following are themselves a collection of different data types?
String
Struct
char
all
Which operator connects the structure name to its member name?
-
=
.
>>
Which of the following cannot be a structure member?
another structure
array
Function
None
Which of the following structure declaration will throw an error?
struct temp{ } s;
main(){}
struct temp{ };
struct temp s;
main(){ }
struct temp s;
struct temp{ };
main(){ }
None
What is the output of this C code?
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
Nothing
Compile error
8
Junk
Size of a union is determined by size of the.
First member in the union
Last member in the union
C. Biggest member in the union
Sum of the sizes of all members
Assuming size of long int is 4 bytes, what will be the output for:
typedef long long int L = 24;
printf("Size of long long int is :");
printf("%d",sizeof(L));
24
4
8
Error
What will be the output
Name:
Subject:
Percentage: 86.50000
Name:Raju
Subject:
Percentage: 86.50000
Name: Raju
Subject: Maths
Percentage: 86.50000
Error
Memory allocated for structure members are always contigious
True
False
What do you understand by:
void update(struct student *s);
update is a function that takes an argument as pointer to structure variable and returns nothing
update is a method that takes structure type variable as parameter
Error, we cannot pass structure variable as pointer to a function
update takes pointer argument but it cannot return void
