•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 402,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,615 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 215 | Replies: 4
![]() |
•
•
Join Date: Jul 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 0
c Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> float avg(float); main() { FILE *p[2]; int k,students=10,subjects=4,i,j,id_number,date_of_birth,fail=0; float marks[100],total=0,avg; char name[30],course_enrolled[30],filename[10]; for(i=1;i<=2;i++) { printf("filename"); scanf("%s",&filename); p[i]=fopen(filename,"w"); printf("Enter Name of Student\n",p[i]); fscanf(stdin,"%s",&name,p[i]); printf("Enter Course In Which Student Is Enrolled\n",p[i]); fscanf(stdin,"%s",&course_enrolled,p[i]); printf("Enter ID Number Of %s Enrolled in Course %s\n",name,course_enrolled,p[i]); fscanf(stdin,"%d",&id_number,p[i]); printf("Enter Date Of Birth Of %s Enrolled in Course %s and\n ID-Number is %d\n",name,course_enrolled,id_number,p[i]); fscanf(stdin,"%d",&date_of_birth,p[i]); for(j=1;j<=4;j++) { printf("Enter Marks for Subject %d for Student %s\n",j,name); fscanf(stdin,"%f",&marks[j]); total=total+marks[j]; if(marks[j]<50) fail=fail+1; else continue; } avg=(total/400)*100; printf("AVERAGE=%f\n",avg); if(avg>=70) printf("Grade A\n"); if(avg>=60&avg<70) printf("Grade B\n"); else if(avg>=50&avg<60) printf("Grade C\n"); else if(avg>=45&avg<50) printf("Grade D\n"); else if(avg>=40&avg<45) printf("Grade E\n"); else if(avg<40) printf("Fail\n"); if(fail>=2) printf("Student is failed and cann;t promote\n"); else continue; fclose (p[i]); } for(k=1;k<=2;k++) { printf("Input filename"); scanf("%s",&filename); p[k]=fopen(filename,"r"); fprintf(stdout,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %d\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,avg); fclose (p[k]); } getch(); }
there is a problem i cann;t save all data in a single file as well as but cann;t use array of pointers in function to save records of 10 students
Last edited by Ancient Dragon : Jul 10th, 2008 at 5:08 am. Reason: add code tags
•
•
Join Date: Dec 2006
Posts: 215
Reputation:
Rep Power: 2
Solved Threads: 16
Pleaseeeeeeeeeeeeeeeeee use code tags
and intendant the code.
ssharish
and intendant the code.ssharish
•
•
Join Date: Aug 2006
Location: Noida, India
Posts: 157
Reputation:
Rep Power: 3
Solved Threads: 16
c Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> float avg(float); main() { FILE *p[2]; int k,students=10,subjects=4,i,j,id_number,date_of_birth,fail=0; float marks[100],total=0,avg; char name[30],course_enrolled[30],filename[10]; for(i=1;i<=2;i++) { printf("filename"); scanf("%s",&filename); p[i]=fopen(filename,"w"); printf("Enter Name of Student\n",p[i]); fscanf(stdin,"%s",&name,p[i]); printf("Enter Course In Which Student Is Enrolled\n",p[i]); fscanf(stdin,"%s",&course_enrolled,p[i]); printf("Enter ID Number Of %s Enrolled in Course %s\n",name,course_enrolled,p[i]); fscanf(stdin,"%d",&id_number,p[i]); printf("Enter Date Of Birth Of %s Enrolled in Course %s and\n ID-Number is %d\n",name,course_enrolled,id_number,p[i]); fscanf(stdin,"%d",&date_of_birth,p[i]); for(j=1;j<=4;j++) { printf("Enter Marks for Subject %d for Student %s\n",j,name); fscanf(stdin,"%f",&marks[j]); total=total+marks[j]; if(marks[j]<50) fail=fail+1; else continue; } avg=(total/400)*100; printf("AVERAGE=%f\n",avg); if(avg>=70) printf("Grade A\n"); if(avg>=60&avg<70) printf("Grade B\n"); else if(avg>=50&avg<60) printf("Grade C\n"); else if(avg>=45&avg<50) printf("Grade D\n"); else if(avg>=40&avg<45) printf("Grade E\n"); else if(avg<40) printf("Fail\n"); if(fail>=2) printf("Student is failed and cann;t promote\n"); else continue; fclose (p[i]); } for(k=1;k<=2;k++) { printf("Input filename"); scanf("%s",&filename); p[k]=fopen(filename,"r"); fprintf(stdout,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %d\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,avg); fclose (p[k]); } getch(); }
At line nos. 10, 23 and 53 CHECK your for loops.
Last edited by Luckychap : Jul 9th, 2008 at 9:39 pm.
When you think you have done a lot, then be ready for YOUR downfall.
•
•
Join Date: Jul 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 0
http://s3.supload.com/free/lastscan-...3716.jpg/view/
here u can see the program that i need. i am really tired of working on it.
1) There is some problem with average as it adds up average marks of last students with current one.
2) i cann;t save all records in a single file !
3) can anyone modify this code with according to the question ("up there on image link").
thanks guys for reply
here u can see the program that i need. i am really tired of working on it.
1) There is some problem with average as it adds up average marks of last students with current one.
2) i cann;t save all records in a single file !
3) can anyone modify this code with according to the question ("up there on image link").
thanks guys for reply
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,721
Reputation:
Rep Power: 36
Solved Threads: 884
Don't double post the problem in multiple threads because it only causes confusion. I'm closing this thread so that the discussion can continue in the other thread.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api blogger blogging blogs code code injection combo dani daniweb data debugging development dreamweaver dropdownlist epilepsy gdata google gpl griefers hackers html innovation javascript key linux microsoft module net news openbsd product programming reuse rss serial source tags vista web wysiwyg xml
- Code 19 Registry Error (Windows NT / 2000 / XP / 2003)
- Why won't this code work? (VB.NET)
- Need help with DirectX code (C)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the C Forum
- Previous Thread: How to find ASCII value of character in c
- Next Thread: Sorting an array of doubles?


Linear Mode