What Does This C Code Do? - Click Quiz

You are given 12 different pieces of C code. Try to match each one with what it does.
Excuse me for using gets() - I really don't want to complicate things
Try the whole series here
Quiz by
akjlddkjslfsd
Rate:
Last updated: December 1, 2023
You have not attempted this quiz yet.
First submittedDecember 1, 2023
Times taken18
Average score58.3%
Report this quizReport
4:00
0
 guessed
12 remaining
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
char a[20];
gets(a);
int j = 0;
for(int i = 0; a[i]; i++) { if(a[i] >= 'A' && a[i] <= 'Z') a[j++] = a[i]; }
a[j] = 0;
puts(a);
char a[20];
gets(a);
for(int i = 0; a[i]; i++) { if(i % 2 == 0) putchar(a[i]); }
putchar('\n');
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", (a < b) ? a : b);
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) { if(a[i] % 2 == 0) r += a[i]; }
printf("%d\n", r);
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a * b);
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", (a > b) ? a : b);
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) r += a[i];
printf("%d\n", r);
char a[20];
int r = 0;
gets(a);
while(a[r]) r++;
printf("%d\n", r);
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) { if(a[i] % 2 == 1) r += a[i]; }
printf("%d\n", r);
int a = 1, b = 1;
printf("%d %d ", a, b);
for(int i = 3; i <= 10; i++) { int t = a; a = b; b = t; a = a + b; printf("%d ", a); }
printf("\n");
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) r += a[i];
r /= sizeof(a) / sizeof(a[0]);
printf("%d\n", r);
Prints the average of an array of integers
Prints the first 10 numbers in the Fibonacci sequence
Prints the sum of all even numbers in an array of integers
Prints the sum of all odd numbers in an array of integers
Prints the sum of an array of integers
Reads a string from stdin and prints every other character
Reads a string from stdin and prints its length
Reads a string from stdin, discards all chars that aren't uppercase letters, then prints the new string
Reads two integers from stdin and prints the maximum of those integers
Reads two integers from stdin and prints the minimum of those integers
Reads two integers from stdin and prints their product
Reads two integers from stdin and prints their sum
Save Your Stats
Your Next Quiz
Name all 50 states in the USA. Easy, right?
Can you name the capitals cities of all 196 countries in the world?
20 random countries have been removed from the map of the world! Can you identify them in 3 minutes?
Click the movies that were directed by Martin Scorsese without clicking on the ones that weren't. Three mistakes ends the quiz.
Comments
No comments yet