Solution for Exercise 12-2
ex1202
#include <stdio.h>
int main()
{
int highscore1,highscore2,highscore3,highscore4;
printf("Your highest score: ");
scanf("%d",&highscore1);
printf("Your second highest score: ");
scanf("%d",&highscore2);
printf("Your third highest score: ");
scanf("%d",&highscore3);
printf("Your fourth highest score: ");
scanf("%d",&highscore4);
puts("Here are your high scores");
printf("#1 %d\n",highscore1);
printf("#2 %d\n",highscore2);
printf("#3 %d\n",highscore3);
printf("#4 %d\n",highscore4);
return(0);
}
Output
Your highest score: 750
Your second highest score: 699
Your third highest score: 675
Your fourth highest score: 666
Here are your high scores
#1 750
#2 699
#3 675
#4 666
Notes
* Imagine the coding it would require if you requested user input to display a specific score. This is the stuff nightmares are made of.
Copyright © 1997-2026 by QPBC.
All rights reserved
