You are on page 1of 5

Assignment - 14

STRUCTURE- stage 1

Assigned Task:

STRUCTURE
1. Write a program using structure for collect student’s Detail to collect the
following Datas:
a. stu_name
b. stu_Idno.
c. stu_age
d. Stu_class
e. Stu_address
f. Stu_pincode
#include<stdio.h>

struct student {
char name[10];
int idno;
int age;
char sec;
char add[10];
int pin;
};
int main ( )
{
int i;
struct student stuarr [10] ;
printf (" \nname \nidno \nage \nsec \naddress \npincode\n");
for(i=0;i<5;i++)
{

scanf("%s %d %d %c %s %d",&stuarr[i] .name,&stuarr[i].idno,


&stuarr[i].age,&stuarr[i].sec,&stuarr[i].add,&stuarr[i].pin);
}
printf (" Name idno age sec, address, pincode\n");
for(i=0;i<5;i++)
{
printf("%s %d %d %c %s %d ",stuarr[i].name,stuarr[i].idno,
stuarr[i].age,stuarr[i].sec,stuarr[i].add,stuarr[i].pin);
printf("\n");
}
}
2. Write a program to collect the candidate’s detail using Structure in C from the
following datas
a. candi_name
b. candi_age
c. candi_gender
d. candi_doorno.
e. candi_streetname
f. candi_city
g. candi_pincode
Program:
#include<stdio.h>

struct can {
char name[20];
int age;
char gender;
int doorno;
char street[20];
char city[20];
int pincode;
};
int main ( )
{
int i;
struct can a [10] ;
printf (" \n candi_name \ncandi_age \ncandi_gender \ncandi_doorno \
ncandi_streetname \n candi_city \ncandi_pincode ");
for(i=0;i<2;i++)
{

scanf("%s %d %c %d %s %s %d \n",&a[i].name,&a[i].age,
&a[i].gender,&a[i].doorno,&a[i].street,&a[i].city,&a[i].pincode);
}
printf (" name\tage\tgender\tdoorno\tstreetname\tcity\tpincode \n");
for(i=0;i<2;i++)
{
printf("\n%s\t %d\t %c \t%d \t%s\t\t%s\t\t%d",a[i].name,a[i].age,
a[i].gender,a[i].doorno,a[i].street,a[i].city,a[i].pincode);
printf("\n");
}
}

You might also like