What will be the result of the following code snippet?
#include <stdio.h>
void solve()
{
char ch[10] = "abcdefghij";
int ans = 0;
for(int i = 0; i < 10; i++)
{
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main()
{
solve();
return 0;
}
TPEC4
Quiz
•
Computers
•
Professional Development
•
Medium
Revathy BD
Used 4+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What will be the result of the following code snippet?
#include <stdio.h>
void solve()
{
char ch[10] = "abcdefghij";
int ans = 0;
for(int i = 0; i < 10; i++)
{
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main()
{
solve();
return 0;
}
45
35
20
100
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
#include "stdio.h"
int main()
{
int x, y = 5, z = 5;
x = y == z;
printf("%d", x);
getchar();
return 0;
}
0
1
5
Compiler Error
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
How is an array initialized in C language?
int a = {1, 2, 3};
int a(3) = [1, 2, 3];
int a[] = new int[3];
int a[3] = {1, 2, 3};
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
How is the 3rd element in an array accessed based on pointer notation?
*(a + 3)
*a + 3
&(a + 3)
(a + 3)
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
How to find the length of an array in C?
sizeof(a[0])
sizeof(a) / sizeof(a[0])
sizeof(a) * sizeof(a[0])
sizeof(a)
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is the output of the following code snippet?
#include <stdio.h>
#include<stdlib.h>
void set(int to)
{
to = (int)malloc(5 sizeof(int));
}
void solve()
{
int ptr; set(ptr); ptr = 10;
printf("%d", ptr);
}
int main()
{
solve();
return 0;
}
10
The program may crash.
Cannot Say
Garbage Value
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
From following which is not the operation of data structure?
Operations that manipulate data in some way
Operations that perform a computation
Operations that check for syntax errors
Operations that check for syntax errors
20 questions
C-Quest
Quiz
•
Professional Development
10 questions
C Programming
Quiz
•
Professional Development
15 questions
Linked List
Quiz
•
Professional Development
10 questions
C Programming
Quiz
•
Professional Development
10 questions
C Code Master lvl 2 A
Quiz
•
Professional Development
15 questions
Flutter Q_0
Quiz
•
Professional Development
15 questions
C PROGRAMMING BASICS-QUIZ-1
Quiz
•
Professional Development
15 questions
C Language Quiz-1
Quiz
•
University - Professi...
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