#include <stdio.h>
int fun(int n) {
if(n == 0) return 0;
return n + fun(n-1);
}
int main() {
printf("%d", fun(3));
return 0;
}
GLITCH_HUNT-ROUND 1
Quiz
•
World Languages
•
University
•
Hard
K.Gowthami Priya
Used 3+ times
FREE Resource
25 questions
Show all answers
1.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int fun(int n) {
if(n == 0) return 0;
return n + fun(n-1);
}
int main() {
printf("%d", fun(3));
return 0;
}
Answer explanation
The function fun(n) calculates the sum of all integers from n to 0. For fun(3), it computes 3 + 2 + 1 + 0 = 6. The correct answer is 6, not 0.
2.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int sum(int a[], int n) {
int s = 0;
for(int i = 0; i < n; i++) s += a[i];
return s;
}
int main() {
int a[] = {2, 4, 6};
printf("%d", sum(a, 3));
return 0;
}
Answer explanation
The function sum calculates the sum of the array elements. For the array {2, 4, 6}, the sum is 2 + 4 + 6 = 12. However, the correct answer is 0, indicating a misunderstanding in the question or answer choices.
3.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int main() {
FILE *f = fopen("nofile.txt", "r");
if(f == NULL)
printf("File error");
else
printf("Opened");
return 0;
}
Answer explanation
The code attempts to open a file that does not exist. Since 'nofile.txt' cannot be opened, 'f' will be NULL, triggering the 'File error' message. The correct answer is 0, indicating the file was not opened.
4.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int main() {
int arr[] = {1, 3, 5, 7, 9};
printf("%d", arr[arr[1]]);
return 0;
}
5.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int main() {
int arr[2][2] = {{1,2},{3,4}};
printf("%d", arr[1][1]);
return 0;
}
6.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
int main() {
FILE *f = fopen("file.txt", "w");
fputs("data", f);
fclose(f);
f = fopen("file.txt", "r");
char c;
while((c = fgetc(f)) != EOF)
printf("%c", c);
fclose(f);
return 0;
}
7.
FILL IN THE BLANK QUESTION
1 min • 1 pt
#include <stdio.h>
void hello() {
printf("Hi ");
}
int main() {
hello();
hello();
return 0;
}
20 questions
Penalaran Umum
Quiz
•
12th Grade - University
20 questions
CLC Stage 1
Quiz
•
6th Grade - University
20 questions
Avancemos 1 U4L2
Quiz
•
6th Grade - University
20 questions
Հայ Գրականություն
Quiz
•
University
20 questions
Οι χρόνοι και οι εγκλίσεις του ρήματος
Quiz
•
12th Grade - University
25 questions
Antonim
Quiz
•
University
20 questions
Dia de los Muertos
Quiz
•
KG - University
20 questions
ふくしゅう1
Quiz
•
University
10 questions
Chains by Laurie Halse Anderson Chapters 1-3 Quiz
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
12 questions
Multiplying Fractions
Quiz
•
6th Grade
30 questions
Biology Regents Review #1
Quiz
•
9th Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
50 questions
Biology Regents Review: Structure & Function
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University
16 questions
Chapter 8 - Getting Along with your Supervisor
Quiz
•
3rd Grade - Professio...
6 questions
Railroad Operations and Classifications Quiz
Quiz
•
University
71 questions
Logos
Quiz
•
3rd Grade - University
8 questions
Mali - Geography
Quiz
•
University