| | |
file and multidimensional array
![]() |
> I need help for this C Program very urgent
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent
Urgency is your problem, not mine.
> please find the attachment below
http://www.catb.org/~esr/faqs/smart-...s.html#formats
I'm not interested in even risking downloading a non-portable file format which is prone to all sorts of virus infections.
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent
Urgency is your problem, not mine.
> please find the attachment below
http://www.catb.org/~esr/faqs/smart-...s.html#formats
I'm not interested in even risking downloading a non-portable file format which is prone to all sorts of virus infections.
>>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.
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
Hi,
I need help for this C Program very urgent. please find the attachment below
And then, maybe we could help.
Last edited by Aia; Aug 6th, 2007 at 6:28 pm.
•
•
Join Date: Jul 2005
Posts: 12
Reputation:
Solved Threads: 2
Hi There,
Here you go. Please find your requsted program below.
Here you go. Please find your requsted program below.
C Syntax (Toggle Plain Text)
/******************************************************************************\ * 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; }
C Syntax (Toggle Plain Text)
gets(sName);
Definitely a show stopper. Do yourself a favor and don't
use gets() anymore. Forget that it exists. Here's why.
C Syntax (Toggle Plain Text)
#include <conio.h> flushall(); getch();
These are not C standards. Best to not use them, specially
to help other people.
![]() |
Similar Threads
- filestream && multidimensional arrays (C++)
- Question regarding multidimensional array for navigation bar (Graphics and Multimedia)
- Sort multidimensional array on more than one column? (ASP)
- multidimensional array merge using PHP (PHP)
- Storing file data in an array? (C++)
- How to Sort a MultiDimensional Array (C)
- multidimensional array (C)
Other Threads in the C Forum
- Previous Thread: Need Help -- Database connectivity in C
- Next Thread: typedef or a multidimensional array?
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






