hi
i need help with my grading program

i need to do something so the menu comes up and make it work property

i have no idea on my switch statement and how to delete student from list please help me

#include <stdio.h>


void main()
{

 int ssn[1000];
 int sex[1000];
 char name[1000][30];
 int Assignment_average[1000];
 int Quiz_Average[1000];
 int participation[1000];
 int Midterm[1000];
 int final[1000];
 int i,j,menu;
 int cnt=0;
 int tot[1000];

 double avr[1000]; 
 int score[1000];
 int best[1000];

printf("1.Print list of  students\n3.Print list of  those whom made an A grade\n4.Print list of  those  whom made an F grade\n5.Print list of  students sorted by name\n6.add student to the class list\n7.delete student from class list\n8.	quit",&menu )
scanf("%d",&menu);

switch(menu)
{
	case 1:
	case 2:
	case 3:
	case 4:
}	
	
 
  if(ssm[i]==-999) break;  //add students  
  printf("Input a Name! =");
  scanf("%s",&name[i]);
  printf("Input a Assignment_average=");
  scanf("%d",&Assignment_average[i]);
  printf("Input a Quiz_Average=");
  scanf("%d",&Quiz_Average[i]);
  printf("Input a participation=");
  scanf("%d",&participation[i]);
  printf("Input a Midterm=");
  scanf("%d",&Midterm[i]);
  printf("Input a final=");
  scanf("%d",&final[i]);
  cnt++;
    }

 

 for(i=0;i {
tot[i]=0.40*Assignment_average[i]+ Quiz_Average[i]*0.15+ participation[i]*0.10+Midterm[i]*0.15+ final[i]*0.20  avr[i]=tot[i]*100;
 }

Dani AI

Generated

Several replies already identify surface problems (malformed prints, unsafe string input, typos). Building on and , a cleaner and more reliable approach is to: 1) keep each student's data together (use a struct), 2) run the menu inside a loop that validates input, and 3) implement deletion by locating the student and shifting the remaining entries. The examples below are compact, safe, and avoid parallel-array pitfalls in the original post.

#include <stdio.h>
#include <string.h>

#define MAX_STUDENTS 1000
#define NAME_LEN 30

typedef struct {
    int ssn;
    char name[NAME_LEN];
    int assignment, quiz, participation, midterm, final;
} Student;

Student students[MAX_STUDENTS];
int count = 0;

Delete by SSN (linear search + memmove) — keeps the array contiguous and updates count:

#include <string.h>

int delete_by_ssn(Student arr[], int *pcount, int target_ssn) {
    for (int i = 0; i < *pcount; ++i) {
        if (arr[i].ssn == target_ssn) {
            if (i < *pcount - 1)
                memmove(&arr[i], &arr[i+1], (*pcount - i - 1) * sizeof(Student));
            (*pcount)--;
            return 1; /* removed */
        }
    }
    return 0; /* not found */
}

Menu skeleton and safe string input: show the menu inside a loop, read the numeric choice with validation, and use fgets (then strip newline) for names to avoid buffer overruns. When computing final scores, use double and apply weighted sums to component percentages (if components are already 0–100, the weighted sum yields 0–100 directly). Watch for the simple typos that appeared in the original (e.g., ssm vs ssn) and initialize counters before use.

These changes address the core problems in the thread: broken menu flow, unsafe input, and deletion logic. Using a struct simplifies printing, sorting, adding, and deleting students and reduces the chance of index mismatches when fields are shifted.

Recommended Answers

All 3 Replies

Ooh, yet another grade supersystem...

Better try to search DaniWeb for grade. There are lots of dozens of grade calculation threads (solved;))...

I would clean up the printf a bit by making it more readable. Also I am not sure why you are passing the argument "&menu" to your printf. Its incorrect in this context.

Something like this would be much easier to read.

printf("1.Print list of  students\n");
printf("3.Print list of  those whom made an A grade\n");
printf("4.Print list of  those  whom made an F grade\n");
printf("5.Print list of  students sorted by name\n");
printf("6.add student to the class list\n");
printf("7.delete student from class list\n");
printf("8.	quit\n");

And after you've read the menu, you need to perform the processing for the menu item selected in your switch case.

switch (menuitem){
  case 1:
    // print list 
    break;
  case 2:
    // print list of A students 
    break;
  ...
  ....

  default:
    break;
}

"Please don't kill the codes,Pay them some respect "
After all,they are "your" codes:

for(i=0;i {
tot[i]=0.40*Assignment_average[i]+ Quiz_Average[i]*0.15+ participation[i]*0.10+Midterm[i]*0.15+ final[i]*0.20  avr[i]=tot[i]*100;
 }

Complete their format at least....

Errors:
>Usage of "&menu" in printf is not only syntactically wrong but also useless.Why do you want to print value of menu there???

>The code :

printf("Input a Name! =");
  scanf("%s",&name[i]);

is incorrect usage.If you want to pick the i th name then

scanf("%s",name[i]);

is enough as per your declaration of name array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.