>>I'm not interested in even risking downloading a non-portable file format which is prone to all sorts of virus infections

Absolutely agree with that -- *.doc files have been known to contains viruses, worms and other kinds of animals. Kg: save your program as *.c and either post it or attach it if its too big to post.

Hi,

I need help for this C Program very urgent. please find the attachment below

Post what the program is suppose to do, and what is not doing correctly. Post any error messages you are getting at compile time, in essence tell us what's the problem that you are having with it.

And then, maybe we could help.

Hi There,
Here you go. Please find your requsted program below.

/******************************************************************************\
 * QUESTION #2                                                                *
 * Create a program that will keep track of 5 students and their grades.      *
 * The grades will be kept in an array of up to 10 grades.                    *
 * To do this, you will need to create a multi-dimensional array of grades    *
 * where each column (or row) is assigned to each student.                    *
\******************************************************************************/



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

float grade[5][10];
char *StudentNames[5]= {0};
int totalStudent=0;

int AddStudentName(void);
int EnterGrades(void);
int DisplayData(void);

int main(int argc, char* argv[])
{
    int i=0,j=0;
    for(i=0;i<5;i++)
        for(j=0;j<10;j++)
            grade[i][j] = -1;

    
    while(1)
    {
        char choice;
        printf("\n\n\n\n");
        printf("\n/**********************************************************\\");
        printf("\n * Chioce           Function                               *");
        printf("\n  ********************************************************* ");
        printf("\n *    1             Add student name.                      *");
        printf("\n *    2             Enter Grades.                          *");
        printf("\n *    3             Display student-grade data.            *");
        printf("\n *  Any othey key   Exit program.                          *");
        printf("\n\\**********************************************************/");
        printf("\nEnter Chioce:..");
        choice=getche();
        switch(choice)
        {
        case '1':
            AddStudentName();
            break;
        case '2':
            EnterGrades();
            break;
        case '3':
            DisplayData();
            break;
        default:
            return 0;
        }

    }


    return 0;
} //end main 

int AddStudentName(void)
{
    if(totalStudent < 5)
    {
        char sName[50]={0};
        totalStudent++;
        printf("\nEnter Student %d name(default-Student%d) : ",totalStudent,totalStudent);
        flushall();
        gets(sName);
        if(strlen(sName)==0)
            sprintf(sName,"Student%d",totalStudent);

        StudentNames[totalStudent-1] = (char *)calloc(strlen(sName)+1,sizeof(char));
        strncpy(StudentNames[totalStudent-1],sName,strlen(sName));

    }
    else
    {
        printf("\n **** Maximum 5 student can be entered.  Press any key to continue.");
        getch();
    }
    return 0;
}
int EnterGrades(void)
{
    if(totalStudent != 0)
    {
        int studentNo=0, j=0;
        int choice;
        printf("\nChoice - Student Name");
        for(;studentNo<totalStudent;studentNo++)
            printf("\n%4d - %s",studentNo+1,StudentNames[studentNo]);

        printf("\n\nSelect student for whom you want to enter grade. Enter chioce...");
        choice = getche();
        studentNo = choice-1-'0';

        while(j<10 && grade[studentNo][j]!=-1) j++;

        if(j==10)
            printf("\n10 grades already entered for the selected student. No more grade can be entered.");
        else
        {
            printf("\n Enter Grade : ");
            scanf("%f",&grade[studentNo][j]);
        }
    }
    else
    {
        printf("\nPlease Enter student Names first. Press any key to continue.");
        getch();
    }

    return 0;
}
int DisplayData(void)
{
    if(totalStudent != 0)
    {
        int i=0,j=0;
        for(i=0;i<totalStudent;i++)
        {
            if(StudentNames[i]!=0)
                printf("\n Student Name : %s",StudentNames[i]);

            for(j=0;j<10;j++)
            {
                if(grade[i][j]!=-1)
                    printf("\n\t\t - Grade %d = %d", j+1, grade[i][j]);
                else if(j==0)
                {
                    printf("\n\t** No Grade entered for the student..\n");
                    break;
                }
                else
                {
                    printf("\n");
                    break;
                }

            }
        }
        printf("\n == End of data.. == \n");
    }
    else
    {
        printf("\n======== No data to Display. ========= Press any key to continue.");
        getch();
    }
    getch();
    return 0;
}
gets(sName);

Definitely a show stopper. Do yourself a favor and don't
use gets() anymore. Forget that it exists. Here's why.

#include <conio.h>

flushall();
getch();

These are not C standards. Best to not use them, specially
to help other people.

This article has been dead for over six months. Start a new discussion instead.