Solution for Exercise 14-6
ex1406
#include <stdio.h>
int main()
{
struct scores
{
char name[32];
int score;
};
struct scores player[4];
int x;
for(x=0;x<4;x++)
{
printf("Enter player %d: ",x+1);
scanf("%s",player[x].name);
printf("Enter their score: ");
scanf("%d",&player[x].score);
}
puts("Player Info");
printf("#\tName\tScore\n");
for(x=0;x<4;x++)
{
printf("%d\t%s\t%5d\n",
x+1,player[x].name,player[x].score);
}
return(0);
}
Notes
* The printf() statement at Line 22 may look a bit odd, but it's just the \t escape sequence, which I use to line up output. Those same characters (tabs) appear in the printf() statement at Lines 25 and 26 to line up output.
Copyright © 1997-2025 by QPBC.
All rights reserved
