Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- // Khoi tao data luu cac thuoc tinh no (thuc ra la student code), name va mark
- struct data{
- int no;
- char name [10];
- float mark;
- };
- int main(){
- int stu_num, i; //khai bao stu_num de nhap so luong hoc sinh, bien i de chay dong lap FOR
- struct data stu[10]; //khai bao array stu luu duoc 10 du lieu va mang thuoc tinh cua data (no, name, mark)
- printf("\nHow many student would you like to manage: ");
- scanf("%d", &stu_num);
- //Neu nhap sai thi bat nhap lai trong khoang 1-10
- while(stu_num<1||stu_num>10){
- printf("\nThe number of Student is in range 1 - 10!\nPress any key to continue...");
- getch();
- fflush(stdin);
- printf("\nHow many student would you like to manage: ");
- scanf("%d", &stu_num);
- }
- //Dung dong lap for de nhap du lieu theo so hoc sinh minh da nhap
- for (i=0;i<stu_num;i++){
- printf("\t-Enter Student %d No: ",i+1);
- scanf("%d",&stu[i].no);
- fflush(stdin);
- printf("\t-Enter Student %d Name: ",i+1);
- gets(stu[i].name);
- printf("\t-Enter Student %d Mark: ",i+1);
- scanf("%f",&stu[i].mark);
- }
- printf("\n\n--------- STUDENT INFORMATION ---------");
- printf("\n\t (Note: P - Pass, R - Ref)");
- printf("\n No Code Name Mark P/R");
- printf("\n-------+-------+-------+-------+-------");
- for (i=0;i<stu_num;i++){
- printf("\n%d\t%d\t%s\t%.2f\t",i+1,stu[i].no,stu[i].name,stu[i].mark);
- if (stu[i].mark<5){
- printf("R");
- }
- else{
- printf("P");
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement