English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

define a structure called student.. use the arrays name[20],int age,charclass[20],float marks1,float marks2 and float total.write and test program to get data,compute total through a function call and print all details for five students

2006-09-11 03:34:15 · 4 answers · asked by Real Cowboy 1 in Computers & Internet Programming & Design

its a program in C and ITS NOT MY HOMEWORK!

2006-09-11 03:35:54 · update #1

4 answers

#include
#include

struct stud
{
char name[20];
int age;
char class[20];
float m1,m2;
float total;
}a[5];

void display()
{int i=0;
for(i=0;i<5;i++)
{
printf("the details of student no %d is:",i);
printf("name=%s \t age=%d \t class=%s \t total marks=%f",a[i].name,a[i].age,a[i].class,a[i].total);
}

}
void add()
{int i=0;
for(i=0;i<5;i++)
{
printf("enter the name,age,class,marks1,marks2 for the student no %d",i);
scanf(" %s %d %s %f %f",&a[i].name,&a[i].age,&a[i].class,&a[i].m1,&a[i].m2);
}

}

void sum()
{int i=0;
for(i=0;i<5;i++)
{
a[i].total=a[i].m1+a[i].m2;
}
}

int main()
{
add();
sum();
display();
return;
}

2006-09-11 03:53:36 · answer #1 · answered by Anonymous · 0 0

Tough!

2006-09-11 04:32:20 · answer #2 · answered by ToX 3 · 0 0

Try this web page

2006-09-11 03:52:38 · answer #3 · answered by AnalProgrammer 7 · 0 0

Sounds like homework to me, I am not helping you cheat...

2006-09-11 03:38:56 · answer #4 · answered by barter256 4 · 1 0

fedest.com, questions and answers