Click here for important information about Computing.net.

Have been getting errors trying to solve the program.

January 2, 2021 at 06:45:51
Specs: Windows 10, 4GB RAM
Write a C program that uses array to accept marks from 5 subjects.
The program should
(i) Find and display the total and average marks.
(ii) Display the grade based on average using the following rule.
70 and above A
60 to below 70 B
50 to below 60 C
40 to below 50 D
below 40 F
(iii) count and display the number of the subject failed
(iv) Display the recommendation based on the subjects failed based on the table below
subjects failed recommendation
0 Proceed to next level
1 and 2 Take a supplementary exam
3 and 4 Repeat the failed units
Above 4 Discontinue from the course

message edited by RomGeek


See More: Have been getting errors trying to solve the program.


#1
January 2, 2021 at 21:53:40
This is not the do my homework forum

=====================

M2


Reply ↓  Report •

#2
January 3, 2021 at 01:21:31
Without showing us your program and telling us what errors you are getting there is little that anyone can do to sugget where you are going wrong.

Reply ↓  Report •

#3
January 3, 2021 at 01:30:39
Its not a homework, am still trying to learn this language and am using this problems to understand it better.

message edited by RomGeek


Reply ↓  Report •

Related Solutions

#4
January 3, 2021 at 03:02:23
So show us what you've done.

Reply ↓  Report •

#5
January 3, 2021 at 03:55:51
This should be part of your reply to the request to show us
what you have done, but I'm curious how you plan to input
the data, and whether you plan to save the data or throw it
away since this is just a learning exercise.

-- Jeff, in Minneapolis


Reply ↓  Report •

#6
January 3, 2021 at 10:38:43
never mind guys i finally managed to fix it

Reply ↓  Report •

#7
January 3, 2021 at 10:41:07
#include <stdio.h>
#include <stdlib.h>
int main() {
//declaring all local variable
int values[5], sum, average, failed=0,i,b,length;
char grade[5];
start:
printf("Enter 5 marks separated by space: \n");
//putting user input into the arrary
for(i=0; i < 5; i++){
scanf("%d",&values[i]);
}
// grading user input
for(i = 0; i < 5; i++) {
if(values[i] >= 70 && values[i] <= 100){
grade[0] = 'A';
printf("%d is a grade of %c \n",values[i],grade[0]);
}
else if(values[i] >= 60 && values[i] < 70){
grade[1] = 'B';
printf("%d is a grade of %c \n",values[i],grade[1]);
}
else if(values[i] >= 50 && values[i] < 60){
grade[2] = 'C';
printf("%d is a grade of %c \n",values[i],grade[2]);
}
else if(values[i] >= 40 && values[i] < 50){
grade[3] = 'D';
printf("%d is a grade of %c \n",values[i],grade[3]);
}
else if(values[i] >= 0 && values[i] < 40 ) {
grade[4] = 'F';
printf("%d is a grade of %c \n",values[i],grade[4]);
}
else{
printf("%d is beyond 0-100 bracket\n",values[i]);
}

}
// Evaluation of user data
sum=values[0]+values[1]+values[2]+values[3]+values[4];
average=sum/5;
printf("\nTotal Marks %d ",sum);
printf("\nAverage Marks %d ",average);
for(b=0;b<=4;b++){
if(values[b]<=40){
printf("\n%d is a fail",values[b]);
failed=failed+1;
}
}
printf("\nFailed %d :",failed);
if(failed==0){
printf("Proceed to the next level");
}
else if(failed>=1&&failed<=2){
printf("Take supplementary on the following units");
}
else if(failed==3||failed==4){
printf("Repeat course");
}
else{
printf("Discontinued from the course");
}
return 0;
}


Reply ↓  Report •

#8
January 3, 2021 at 10:42:09
i had messed up this section

sum=values[0]+values[1]+values[2]+values[3]+values[4];
average=sum/5;
printf("\nTotal Marks %d ",sum);
printf("\nAverage Marks %d ",average);
for(b=0;b<=4;b++){
if(values[b]<=40){
printf("\n%d is a fail",values[b]);
failed=failed+1;


Reply ↓  Report •

#9
January 3, 2021 at 10:43:13
but if you have a better way of doing it, i wont mind

Reply ↓  Report •

Ask Question