How to fix this zeros??  Here's the code! #include struct student //Defining structure { int id; char name[20]; float percentage; }; void main(){ //Program execution starts int n, passedCount = 0; //Variable for user input output float highestGrade = 0; //variable for output highest score printf("Enter Number of Records: "); scanf("%d",&n); //user input number of students struct student record[n]; //defining array of size n for (int i = 0; i < n; i++){ //running loop n times printf("\nRecords of STUDENT: %d\n",i+1); printf("ID: "); scanf("%d",&record[i].id); //user input student id printf("\nName: "); scanf("%s",record[i].name); //user input student name printf("\nPercentage: "); scanf("%f",&record[i].percentage); //user input student percentage //comparing entered percentage with already stored highest if (record[i].percentage > highestGrade) highestGrade = record[i].percentage; //checking whether the student passed if (record[i].percentage > 70 && record[i].percentage <= 100) passedCount++; } //Displaying output printf("\n\nHighest Grade: %f\n",highestGrade); printf("Total No. of Passed: %d\n",passedCount); //number of student failed = total - passed printf("Total No. of Failed: %d\n",n-passedCount);

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question
100%

How to fix this zeros?? 

Here's the code!

#include<stdio.h>
struct student //Defining structure
{
int id;
char name[20];
float percentage;
};
void main(){ //Program execution starts
int n, passedCount = 0; //Variable for user input output
float highestGrade = 0; //variable for output highest score
printf("Enter Number of Records: ");
scanf("%d",&n); //user input number of students
struct student record[n]; //defining array of size n
for (int i = 0; i < n; i++){ //running loop n times
printf("\nRecords of STUDENT: %d\n",i+1);
printf("ID: ");
scanf("%d",&record[i].id); //user input student id
printf("\nName: ");
scanf("%s",record[i].name); //user input student name
printf("\nPercentage: ");
scanf("%f",&record[i].percentage); //user input student percentage
//comparing entered percentage with already stored highest
if (record[i].percentage > highestGrade)
highestGrade = record[i].percentage;
//checking whether the student passed
if (record[i].percentage > 70 && record[i].percentage <= 100)
passedCount++;
}
//Displaying output
printf("\n\nHighest Grade: %f\n",highestGrade);
printf("Total No. of Passed: %d\n",passedCount);
//number of student failed = total - passed
printf("Total No. of Failed: %d\n",n-passedCount);
}

Look in the Expected Results in the Outputs!

LAST RUN on 3/28/2021, 1:12:30 AM
Check 1 failed
Output:
Enter Number of Records:
Records of STUDENT: 1
ID:
Name:
Percentage:
Records of STUDENT: 2
ID:
Name:
Percentage:
Records of STUDENT: 3
ID:
Name:
Percentage:
Highest Grade: 90.50000o
Total No. of Passed: 2
Total No. of Failed: 1
Expected:
Enter Number of Records:
Records of STUDENT: 1
ID:
Name:
Percentage:
Records of STUDENT: 2
ID:
Name:
Percentage:
Records of STUDENT: 3
ID:
Name:
Percentage:
Highest Grade: 90.50
Total No. of Passed: 2
Total No. of Failed: 1
Check 2 failed
Output:
Enter Number of Records:
Records of STUDENT: 1
ID:
Name:
Percentage:
Records of STUDENT: 2
ID:
Name:
Percentage:
Records of STUDENT: 3
ID:
Name:
Percentage:
Records of STUDENT: 4
ID:
Name:
Percentage:
Records of STUDENT: 5
ID:
Name:
Percentage:
Highest Grade: 99.750000
Total No. of Passed: 3
Expected:
Enter Number of Records:
Records of STUDENT: 1
ID:
Name:
Percentage:
Records of STUDENT: 2
ID:
Name:
Percentage:
Records of STUDENT: 3
ID:
Name:
Percentage:
Records of STUDENT: 4
ID:
Name:
Percentage:
Records of STUDENT: 5
ID:
Name:
Percentage:
Highest Grade: 99.75
Total No. of Passed: 3
Total No. of Failed: 2
Transcribed Image Text:LAST RUN on 3/28/2021, 1:12:30 AM Check 1 failed Output: Enter Number of Records: Records of STUDENT: 1 ID: Name: Percentage: Records of STUDENT: 2 ID: Name: Percentage: Records of STUDENT: 3 ID: Name: Percentage: Highest Grade: 90.50000o Total No. of Passed: 2 Total No. of Failed: 1 Expected: Enter Number of Records: Records of STUDENT: 1 ID: Name: Percentage: Records of STUDENT: 2 ID: Name: Percentage: Records of STUDENT: 3 ID: Name: Percentage: Highest Grade: 90.50 Total No. of Passed: 2 Total No. of Failed: 1 Check 2 failed Output: Enter Number of Records: Records of STUDENT: 1 ID: Name: Percentage: Records of STUDENT: 2 ID: Name: Percentage: Records of STUDENT: 3 ID: Name: Percentage: Records of STUDENT: 4 ID: Name: Percentage: Records of STUDENT: 5 ID: Name: Percentage: Highest Grade: 99.750000 Total No. of Passed: 3 Expected: Enter Number of Records: Records of STUDENT: 1 ID: Name: Percentage: Records of STUDENT: 2 ID: Name: Percentage: Records of STUDENT: 3 ID: Name: Percentage: Records of STUDENT: 4 ID: Name: Percentage: Records of STUDENT: 5 ID: Name: Percentage: Highest Grade: 99.75 Total No. of Passed: 3 Total No. of Failed: 2
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage