Font size
WorksheetsC Programming Lab Quiz-1
Total questions: 19
Worksheet time: 15mins
What will happen when this program is executed?
int i = 1;
while(i <= 5)
{
if(i == 3)
continue;
printf("%d ", i);
i++;
}
infinite loop
compile time error
What will be the output?(type your answer)
int count = 0;
for(int i = 1; i <= 4; i++)
{
for(int j = i; j <= 4; j++)
{
count++;
}
}
printf("%d", count);
(a)
What will be the output(count value)?
int count = 0;
for(int i = 1; i <= 3; i++)
{
for(int j = 1; j <= 5; j++)
{
if(j == i)
break;
count++;
}
}
printf("%d", count);
What will be the output?
#include <stdio.h>
int main(){
int i;
i = 1, 2, 3;
printf("i = %d\n", i);
return 0;
}
What will be the output?
int a = 5, b = 10, c;
c = (a > b) ? a : (b > 7 ? b : 7);
printf("%d", c);
int a = 1, b = 2;
switch(a + b)
{
case 1:
printf("One");
break;
case 3:
printf("Three");
break;
case 1 + 2:
printf("Again Three");
break;
default:
printf("Default");
}
Three
Again Three
Default
Compilation Error
Which of the following is a valid declaration?
int 1num;
float num;
char 9c;
double-int x;
What would be output?
int a = 10;
float b = 3;
printf("%f", a / b);
3.0
3.33
3
What would be output?
int x = 1;
if(x == 1)
printf("A");
if(x == 1)
printf("B");
else
printf("C");
int i = 1;
while(i <= 5);
{
printf("%d ", i);
i++;
}
1 2 3 4 5
Infinite loop.
What would be output?
for(int i = 1; i <= 5; i++)
{
if(i == 3)
continue;
printf("%d ", i);
}
int i = 1;
while(i++ <= 3){
printf("%d ", i);
}
char x = 120;
while(x > 0)
{
printf("%d ", x);
x++;
}
Infinite loop
Prints 120 to 127
Prints 120 to 255
INo output
Which of the following sequences correctly represents the stages involved when a C program is executed?
Source Code → Compiler → Preprocessor → CPU → Output
Source Code → Preprocessor → Compiler → Linker → Loader → CPU → Output
Source Code → Compiler → Linker → Preprocessor → CPU → Output
Source Code → Preprocessor → CPU → Compiler → Output
What would be outpu t( Assume that during runtime you have taken input as 6 in your scanf function) ?
#include <stdio.h>
int main(){
int x;
int a, b;
a = printf("Hello");
b = scanf("%d", &x);
printf("%d", a + b);
return 0;
}
When your C program does NOT give the expected output, what is the first thing you do?
Stare at the screen silently and rethink life choices
Run it again, because maybe the computer didn’t understand you the first time
Look at the professor and pretend it’s “almost correct”
Blame the compiler version
What would be output?
int a = 5, b = 2;
int c;
c = a * b + a / b;
printf("%d", c);
(a)
int x = 0;
while(x = 5)
{
if(x == 3)
break;
printf("%d ", x);
x--;
}
Compilation error
5 4 3
5 4 3 2 1
Infinite loop
What do you expect most from your C programming professor?
Clear explanations with simple examples
More hands-on coding and lab practice
Help in understanding logic and problem-solving
Support for exams, interviews, and real-world applications
Just leave us early from programming class
