c quiz
DESCRIPTION
play a free C Language Quiz by choosing levels & test your knowledge.TRANSCRIPT
Powerpoint TemplatesPage 1
Powerpoint Templates
Anjuman College of Engineering and Technology, Sadar, Nagpur.
Computer Science and engineering department
presents
Envisage’13
“Over C War”By, Shabina Parveen
Powerpoint TemplatesPage 2
RULES Each Easy level question consists of 5
marks.Each Medium level question consists of 10
marksEach Hard level question consists of 15
marksAccording to the level chosen for betting,
for each correct answer plus marks & for each wrong answer respective marks will be deducted from the actual score
Powerpoint TemplatesPage 3
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 4
Question
Powerpoint TemplatesPage 5
Answer
Dennis Ritchie…
Powerpoint TemplatesPage 6
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 7
QuestionWould the following program give a
compilation error or warning?
#include<stdio.h> int main()
{
float I =10, *j;
void *k;
k = &I;
j = k;
printf(“%f\n”, *j);
return 0;
}
a. Yes b. No
Powerpoint TemplatesPage 8
Answer
b. No
Powerpoint TemplatesPage 9
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 10
QuestionPredict the output:
# define SQUARE(x) x*x;
inline float square(float y)
{
return y*y;
}
int main()
{
float a = 0.5, b = 0.5, c, d;
c= SQUARE (++a)l;
d = square (++b);
return 0;
}
Powerpoint TemplatesPage 11
Answer
Output: during preprocessing the macro SQUARE gets expanded into c=++x *++x;
You can notice the undesirable side effect in this macro expansion; the output is unpredictable because such side effect must not appear in inline function.
Powerpoint TemplatesPage 12
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 13
Question Which of the following statement
is true about the >> operator?
a. It divides a positive value by a power of two.
b. It multiplies a positive value by a power of two.
c. It adds a positive value with a power of two.
d. It subtracts from a positive value a power of two.
Powerpoint TemplatesPage 14
Answer
a. It divides a positive value by a power of two.
Powerpoint TemplatesPage 15
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 16
Question would the following code compile?
#include<stdio.h>
int main()
{
int a = 10, *j; a. Yes
void *k; b. no
j= k = &a;
j++;
k++;
printf(“%u %u\n , j, k”);
return 0;
}
Powerpoint TemplatesPage 17
Answer
b. No
Powerpoint TemplatesPage 18
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 19
QuestionPredict the output:
#include<stdio.h>
int main()
{
int a[]={0,1,2,3.4};
int i , *p;
for(p=arr,i=0; p+i<=arr+4 ; p++ , i++)
printf(“%d”, , *(p+1));
return 0;
}
Powerpoint TemplatesPage 20
Answer
Output: 024
Powerpoint TemplatesPage 21
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 22
Question Which of the following
statement is correct?
a. Int a=64<<2;
b. Float a =6.42<<2;
c. Double a = 3.33<<2;
d. Long double a =3.67<<2;
Powerpoint TemplatesPage 23
Answer
a. Int a=64<<2;
Powerpoint TemplatesPage 24
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 25
Question Would the following program give a compilation
error or warning?
#include<stdio.h>
int main()
{
int *p1, i=25; a. Yes
void *p2; b. no
p1=&i;
p2=&i;
p1=p2;
p2=p1;
return 0;
}
Powerpoint TemplatesPage 26
Answer
b. No
Powerpoint TemplatesPage 27
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 28
Question
• In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain?
• A. "I am a boy\r\n\0"
• B. "I am a boy\r\0"
• C. "I am a boy\n\0"
• D. "I am a boy"
Powerpoint TemplatesPage 29
Answer
C. "I am a boy\n\0"
Powerpoint TemplatesPage 30
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 31
Question
What would be the result of the expression a^a?
a. 0
b. 1
c. Sum of two operands
d. Multiplication of two operands
Powerpoint TemplatesPage 32
Answer
a. 0
Powerpoint TemplatesPage 33
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 34
Question Would the following program give a
compilation error or warning?
#include<stdio.h>
int main()
{
float *p1,i=25.50; a. Yes
char *p2; b. No
p1=&i;
p2=&i;
return 0;
}
Powerpoint TemplatesPage 35
Answer
a. Yes
Powerpoint TemplatesPage 36
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 37
Question
Write a program in C to display any message without using semi colon anywhere in program?
Powerpoint TemplatesPage 38
Answer
#include <stdio.h>
void main()
{
if(printf(”Hello”))
{}
NOTE: We can write the printf inside while or switch as well for same result.
Powerpoint TemplatesPage 39
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 40
QuestionWhat will be the output of the code
snippet given below:
#include<stdio.h>
Void main()
{
Int a =10,b =65;
Printf(“%d”,a<<(a&b));
}
a. 65 c. 0
d. 1 b. 10
Powerpoint TemplatesPage 41
Answer
b. 10
Powerpoint TemplatesPage 42
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 43
Question Predict the output:
#include<stdio.h>
int main()
{
int a[]={10,20,30,40,50};
int j;
for(j=0;j<5;j++)
{
printf(“%d\n”, *a);
a++;
}
return 0;
}
Powerpoint TemplatesPage 44
Answer
Output:
Error message: Lvalue required in function main
Powerpoint TemplatesPage 45
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 46
Question
#include<stdio.h>
int main()
{
char str[20] = "Hello";
char *const p=str;
*p='M';
printf("%s\n", str);
return 0;
}
Powerpoint TemplatesPage 47
Answer
MELLO
Powerpoint TemplatesPage 48
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 49
Question Who were the two main individuals
involved in development of K&R standard for C language?
a.Dennis Ritchie & John Von Neumann
b.Brian Kernighan & Dennis Ritchie
c. Grace Hopper & Niklaus Wirth
d. Dennis Ritchie & Bjarne Stroustroup
Powerpoint TemplatesPage 50
Answer
Brian Kernighan and Dennis Ritchie
•
Powerpoint TemplatesPage 51
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 52
Question Predict the output:
#include<stdio.h>
int main()
{
float a[]={13.24, 1.5, 1.5, 5.4, 3.5};
float *j, *k;
j=a;
k=a+4;
i = j*2;
k =k/2;
printf(“%f %f\n”, *j. *k);
return 0;
}
Powerpoint TemplatesPage 53
Answer
Output:
Error message: illegal use of pointer in function main
Powerpoint TemplatesPage 54
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 55
Questionvoid main(){
int i=10;
static int x=i;
if(x==i)
printf("Equal");
else if(x>i)
printf("Greater than");
else
printf("Less than");
}
Powerpoint TemplatesPage 56
Answer
Compiler error
Powerpoint TemplatesPage 57
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 58
Question
Which of the following utility is used for compiling and linking the program?
a. Make
b. Makefile
c. Compiler
d. linker
Powerpoint TemplatesPage 59
Answer
a. Make
Powerpoint TemplatesPage 60
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 61
Question Would the following program give a
compilation error or warning?
#include<stdio.h>
int main()
{
char a[]=”sunstroke”; a. Yes
char *p = “coldwave”; b. Noa = “coldwave”;
p = “sunstroke”;
printf(“%s %s\n”, a, p);
return 0;
}
Powerpoint TemplatesPage 62
Answer
b. No
Powerpoint TemplatesPage 63
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 64
Question
Write a c program to add two
numbers without add operator?
Powerpoint TemplatesPage 65
Answer
#include <stdio.h>
#include <conio.h>
int main(){
int a=1,b=2,c;
c=a-(-b);
printf(“%d”,c);
getch();
return 0;
}
Powerpoint TemplatesPage 66
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 67
Question
Which of the following function is used to copy data types other than strings from one variable to another?
a. memcpy() c. objcpy()
b. datacpy() d. strcpy()
Powerpoint TemplatesPage 68
Answer
a. memcpy()
Powerpoint TemplatesPage 69
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 70
Question
Predict the output:
#include<stdio.h>
#include<string.h>
int main()
{
char s[]=”rendezvous !”;
printf(“%d\n”, *(s + strlen (s)));
return 0;
}
Powerpoint TemplatesPage 71
Answer
Output: 0
Powerpoint TemplatesPage 72
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 73
QuestionWhat will be the output of the
code snippet given below?
#include<stdio.h>
Void main()
{
Char ch = ‘A’;
Printf(“%d”, ch | ‘A’ & ‘Z’);
}
Powerpoint TemplatesPage 74
Answer
65
Powerpoint TemplatesPage 75
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 76
Question Consider the following program
segment: int a=35;
int *b;
b= &a;
A. b contains address of an int
B. value at address contained in b is an int.
C. b is a pointer which points in the direction of an int.
D. all of the above
Powerpoint TemplatesPage 77
Answer
d. all of the above
Powerpoint TemplatesPage 78
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 79
Question
Predict the output:
#include<stdio.h>
#include<string.h>
int main()
{
printf(5 + “fascimile”);
return 0;
}
Powerpoint TemplatesPage 80
Answer
Output: mile
Powerpoint TemplatesPage 81
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 82
Question
Predict the output:
#define call(x) #x
void main(){
printf("%s",call(c/c++));
}
Powerpoint TemplatesPage 83
Answer
c/c++
Powerpoint TemplatesPage 84
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 85
Question
In which header file is the NULL macro defined?
a. <stdio.h>
b. <stddef.h>
c. # define
d. All of the above
Powerpoint TemplatesPage 86
Answer
c. All of the above
Powerpoint TemplatesPage 87
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 88
Question
Predict the output:
#include<stdio.h>
int main()
{
int arr[12];
printf(“%d\n”, sizeof(arr));
return 0;
}
Powerpoint TemplatesPage 89
Answer
Output: 24
Powerpoint TemplatesPage 90
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 91
Questionstruct marks{
int p:3;
int c:3;
int m:2;
};
void main()
{
struct marks s={2,-6,5};
printf("%d %d %d",s.p,s.c,s.m);
}
Powerpoint TemplatesPage 92
Answer
2 2 12 2 1
Powerpoint TemplatesPage 93
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 94
Question
Is the NULL pointer same as an uninitialized pointer ?
a. Yes
b. No
Powerpoint TemplatesPage 95
Answer
b. No
Powerpoint TemplatesPage 96
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 97
Question
What is the current version of standard for c language was approved in December 2011?
Powerpoint TemplatesPage 98
Answer
C11
Powerpoint TemplatesPage 99
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 100
Question
Predict the output:
void main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}
Powerpoint TemplatesPage 101
Answer
31 19
Powerpoint TemplatesPage 102
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 103
Question
State true or false:
Multiplication of a pointer and an unsigned integer is allowed
a. True
b. false
Powerpoint TemplatesPage 104
Answer
b. False
Powerpoint TemplatesPage 105
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 106
Question
• In which numbering system can the binary number 1011011111000101 be easily converted to?
A. Decimal system
B. Hexadecimal system
C. Octal system
D. No need to convert
Powerpoint TemplatesPage 107
Answer
Hexadecimal system
Powerpoint TemplatesPage 108
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 109
Question
Predict the output:
void main()
{
int a=-12;
a=a>>3;
printf("%d",a);
}
Powerpoint TemplatesPage 110
Answer
-2
Powerpoint TemplatesPage 111
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 112
Question
Does mentioning the array name gives the base address in all the contexts?
a. Yes
b. no
Powerpoint TemplatesPage 113
Answer
b. No
Powerpoint TemplatesPage 114
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 115
Question
• What is the difference between #include <> and #include “ ” ?
Powerpoint TemplatesPage 116
Answer
#include <> ---- > specifically used for built in header file.
#include ” ” ----->specifically used for user defined/created n header files.
Powerpoint TemplatesPage 117
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 118
Question
Assuming, integer is 2 byte, What will be the output of the program?
#include<stdio.h>
int main()
{
printf("%x\n", -1>>1);
return 0;
}
Powerpoint TemplatesPage 119
Answer
ffff
Powerpoint TemplatesPage 120
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 121
Question
A pointer to a block of memory is effectively same as the array
a. True
b. False
Powerpoint TemplatesPage 122
Answer
a. True
Powerpoint TemplatesPage 123
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 124
Question
Find the ERROR:
void main()
{
int const * p=5;
printf("%d",++(*p));
}
Powerpoint TemplatesPage 125
Answer
Compiler error: Cannot modify a constant value.
Powerpoint TemplatesPage 126
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 127
Question
Predict the output:
#include "string.h"
void main(){
clrscr();
printf("%d%d",sizeof("string"),strlen("string");
getch();
}
Powerpoint TemplatesPage 128
Answer
7 6
Powerpoint TemplatesPage 129
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 130
Question What does the following
declaration mean:
a. index of the pointer variable
b. memory location as 10
c. ptr is a pointer to an array of 10 integers
d. none of the above
Powerpoint TemplatesPage 131
Answer
c. ptr is a pointer to an array of 10 integers
Powerpoint TemplatesPage 132
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 133
Question
Two different operators would always have different Associativity.
A. Yes B. No
Powerpoint TemplatesPage 134
Answer
NO
Powerpoint TemplatesPage 135
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 136
QuestionPredict the output:
#include<stdio.h>
void main()
{
int i;
For(i=0;i++<10;)
Printf(“%d\n”,i);
}
Powerpoint TemplatesPage 137
Answer
2
3
4
5
6
7
8
9
10
Powerpoint TemplatesPage 138
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 139
Question
Predict the output:
#include<stdio.h>
int main()
{
printf(“%c”, “abcdefgh”[4]);
return 0;
}
Powerpoint TemplatesPage 140
Answer
0
Powerpoint TemplatesPage 141
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 142
Question
• Data written into a file using fwrite() can be read back using fscanf()
A. True B. False
Powerpoint TemplatesPage 143
Answer
FALSE
Powerpoint TemplatesPage 144
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 145
Question
What the following code will display?
void main()
{
printf("%s",__DATE__);
}
Powerpoint TemplatesPage 146
Answer
Current system DATE
Powerpoint TemplatesPage 147
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 148
Question
Predict the output:
#include<stdio.h>
int main()
{
char str[7] = “strings”;
printf(“%s\n” , str);
return 0;
}
Powerpoint TemplatesPage 149
Answer
Output: cannot predict
Powerpoint TemplatesPage 150
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 151
QuestionWhat do the functions atoi()?
A. is a macro that converts integer to character.
B. It converts an integer to string
C. It converts a floating point number to string
Powerpoint TemplatesPage 152
Answer
is a macro that converts integer to character
Powerpoint TemplatesPage 153
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 154
QuestionPredict the output:
void main()
{
printf("%s","c" "question" "bank");
}
A. c question bank
B. bank
C. cquestionbank
D. Compiler error
Powerpoint TemplatesPage 155
Answer
cquestionbank
Powerpoint TemplatesPage 156
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 157
Question Would the following code
compile successfully?
# include<stdio.h>
int main()
{
printf(“%c”, 7[“sundaram”]);
return 0;
}
Powerpoint TemplatesPage 158
Answer
Ans: Yes
Powerpoint TemplatesPage 159
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 160
Question
Give the output:
main(){#define a 50printf("%d",a);}
Powerpoint TemplatesPage 161
Answer
50
Powerpoint TemplatesPage 162
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 163
QuestionGive the output:
void main(){
char *str="c-pointer";
printf("%*.*s",10,7,str);
}
(a. c-pointer
b. c-pointer
c. c-point
d. cpointer null null
Powerpoint TemplatesPage 164
Answer
c-point
Powerpoint TemplatesPage 165
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 166
Question
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
printf("%p\n", main());
return 0;
}
Powerpoint TemplatesPage 167
Answer
It prints garbage values infinitely
Powerpoint TemplatesPage 168
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 169
Question• Find the error:typedef struct
{
int data;
NODEPTR link;
}*NODEPTR;
Powerpoint TemplatesPage 170
Answer
Error: typedef cannot be used until is define
Powerpoint TemplatesPage 171
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 172
Question
• Predict the output:
#include<stdio.h>
void main()
{
int i;
For(i=0;++i<=10;)
Printf(“%d\n”,i);
}
Powerpoint TemplatesPage 173
Answer
1
2
3
4
5
6
7
8
9
Powerpoint TemplatesPage 174
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 175
QuestionPredict the output: #include<stdio.h>
#include<string.h>
Int main
{
Char str1[]=“learn through IndiaBIX\0.com”, str2[120];
Char *p;
P=(char*)memccpy(str2,str1,’I’,strlen(str1));
*p=‘\0’;
Printf(“%s”,str2);
Return 0;}
Powerpoint TemplatesPage 176
Answer
“learn through indi”
Powerpoint TemplatesPage 177
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 178
Question
State true or false:
• In place of the condition in a while loop structure there can be any other valid expression
Powerpoint TemplatesPage 179
Answer
True
Powerpoint TemplatesPage 180
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 181
Question
Predict the output:
#include<stdio.h>
Void main()
{
Char arr[7]=“NETWORK”;
Printf(“%s”,arr);
}
Powerpoint TemplatesPage 182
Answer
Garbage value
Powerpoint TemplatesPage 183
Categories
Easy
Medium
Hard
Powerpoint TemplatesPage 184
Question
• What does the above flowchart shows?
Initialize
Test
Body of loop
increement
Stop
START
False
True
Powerpoint TemplatesPage 185
Answer
Shows the flowchart of FOR LOOP
Powerpoint TemplatesPage 186
Categories
Easy
Medium
Hard