I'm supposed to write a program that prompts for and reads in test scores with integer values between 0 and 100 and enter no more than 35 test scores. Use a preprocessor directive to define this value. User input will be complete when the user enters a -1 for the test score. When all of the test scores have been entered, the program will print out the scores. Use a while or do-while loop to read in the values. Use a for loop to print out the values. It compiles but when I run it the following message appears "segmentation fault." Is there something wrong with my code? HELP?!
Code:
#include <stdio.h>
#define SIZE 35
int main (void)
{
int nums[SIZE];
int count=0;
int i;
int tests;
while (nums[i] >= 0)
{
printf("Enter test score %d: ", nums[i]);
scanf("%d", &nums[i]);
}
for (i=0; i<SIZE; i++)
{
printf("Number of test scores entered: %d", tests);
printf("Tests scores entered: %d", count);
}
return 0;
}
The output is supposed to look like this:
Code:
Enter test score 1: 88 Enter test score 2: 67 Enter test score 3: 74 Enter test score 4: 94 Enter test score 5: -1 Number of scores entered: 4 Test scores entered : 88 67 74 94