What is the output of the following program?
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 5; i++);
printf("%d ", i);
return 0;
}
Learn2Code
Quiz
•
Engineering
•
Professional Development
•
Hard
arun h
Used 1+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following program?
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 5; i++);
printf("%d ", i);
return 0;
}
Prints 0 1 2 3 4
Prints 5 only
Infinite loop
Compilation error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of executing the following code?
#include <stdio.h>
int main() {
for (int j = 0; j < 3; j++) {
printf("Hello World\n");
}
return 0;
}
Hello World Hello World Hello World
3 times Hello World
Compilation error
Hello World
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the result of the following code?
#include <stdio.h>
int main() {
int a = 10, b = 0;
printf("%d", a / b);
return 0;
}
0
10
Runtime error (division by zero)
Compilation error
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will happen when you run this program?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[5]);
return 0;
}
Output is 5
Output is 0
Undefined behavior / garbage value
Compilation error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What’s wrong in the following code?
#include <stdio.h>
int main() {
int i = 1;
while (i <= 5) {
printf("%d ", i);
}
return 0;
}
Infinite loop
Compilation error
Prints 1 to 5
Prints 1 repeatedly and exits
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of this code?
#include <stdio.h>
int main() {
int a = 7;
if (a = 10) {
printf("Condition is true\n");
}
return 0;
}
Condition is true
Compilation error
Condition is false
No output
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code print?
#include <stdio.h>
int main() {
int a = 5;
printf("%d\n", a++ + ++a);
return 0;
}
11
12
Undefined behavior
Compilation error
30 questions
Module 3 - Introduction to Embedded Systems
Quiz
•
Professional Development
35 questions
Quiz sobre Linhas de Transmissão
Quiz
•
Professional Development
25 questions
Quiz về Radar SSR Mode S
Quiz
•
Professional Development
35 questions
152 revision #2
Quiz
•
Professional Development
25 questions
Exploring Python Basics and Libraries
Quiz
•
Professional Development
25 questions
Azure AI 900 Assignment
Quiz
•
Professional Development
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade