Skip to content

Instantly share code, notes, and snippets.

@qvil
Created June 28, 2017 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qvil/d77d80925b482411cf8c3b88f1de6431 to your computer and use it in GitHub Desktop.
Save qvil/d77d80925b482411cf8c3b88f1de6431 to your computer and use it in GitHub Desktop.
Teacher appointment exam
#include <stdio.h>
int main(void)
{
int score[10] = {1, 2, 3, 4, 5};
int i, op = 2, sum = 0;
switch (op)
{
case 1:
for (i = 0; i < 10; i++)
sum += score[i];
printf("%d \n", sum);
break;
case 2:
for (i = 3; i < 10; i++)
sum += score[i];
printf("%d \n", sum);
default:
for (i = 5; i < 10; i++)
sum += score[i];
printf("%d \n", sum);
break;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment