What will be the output of the following code snippet?
#include <stdio.h>
int main()
{
int a = 3,
b = 5;
int t = a;
a = b;
b = t;
printf("%d %d", a, b);
return 0;
}
SJIT ECE PRACTICE TEST HCL @ 13/3/24
Quiz
•
Professional Development
•
Professional Development
•
Medium
DINESH ADIKESAVAN
Used 2+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
#include <stdio.h>
int main()
{
int a = 3,
b = 5;
int t = a;
a = b;
b = t;
printf("%d %d", a, b);
return 0;
}
5 3
3 3
3 5
5 5
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
#include <stdio.h>
int main()
{
int a[] = {1, 2, 3, 4};
int sum = 0;
for(int i = 0; i < 4; i++) { sum += a[i];
}
printf("%d", sum);
return 0;
}
1
4
10
20
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
int main()
{
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}
2
15
16
18
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int a[] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++) {
if(i % 2 == 0) {
sum += *(a + i);
}
else {
sum -= *(a + i);
}
}
printf("%d", sum);
}
int main() {
solve();
return 0;
}
2
15
3
syntax error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int first = 10, second = 20;
int third = first + second;
{
int third = second - first;
printf("%d ", third);
}
printf("%d", third);
}
int main() {
solve();
return 0;
}
10 30
30 10
10 20
20 10
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int a = 3;
int res = a++ + ++a + a++ + ++a;
printf("%d", res);
}
int main() {
solve();
return 0;
}
12
20
24
18
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the value of x in the following code snippet?
#include <stdio.h>
void solve() {
int x = printf("Hello");
printf(" %d", x);
}
int main() {
solve();
return 0;
}
10
5
1
0
20 questions
SV_MCQ_Assessment1
Quiz
•
Professional Development
15 questions
Programming - Screening Test
Quiz
•
3rd Grade - Professio...
25 questions
PSUEDOCODE 2 CAPGEMINI
Quiz
•
Professional Development
15 questions
Tutorial 1 Chapter 4 C Programming
Quiz
•
Professional Development
15 questions
Q1 Introduction to Python
Quiz
•
Professional Development
15 questions
C Operators
Quiz
•
University - Professi...
16 questions
Identifying Defects in Composite Components
Quiz
•
Professional Development
15 questions
SQL Statements and Queries
Quiz
•
Professional Development
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade