Nakum Anil

PRACTICAL-SET-7

7_1.c
Define a structure type, personal, that would contain person name, date of joining and salary. Using this structure, write a program to read this information for one person from the key board and print the same on the screen.


#include<stdio.h>
#include<conio.h>
struct personal
{
    char person_name[30];
    long int date;
    float salary;
};
void main()
{
    struct personal person;
    clrscr();
    printf("enter the person name,joining date and salary respectively\n");
    gets(person.person_name);
    scanf("%ld",&person.date);
    scanf("%f",&person.salary);
    puts(person.person_name);
    printf("\ndate of joining %ld",person.date);
    printf("\nsalary %f",person.salary);
    getch();
}



7_2.c
Define a structure called cricket that will describe the following information:
a. Player name
b. Team name
c. Batting average


#include<stdio.h>
#include<conio.h>
struct cricket
{
    char player_name[30];
    char team_name[30];
    float batting_average;
};
void main()
{
    struct cricket p1;
    clrscr();
    printf("enter the player name,team name and batting average respectively\n");
    gets(p1.player_name);
    gets(p1.team_name);
    scanf("%f",&p1.batting_average);
    printf("\nplayer name is %s",p1.player_name);
    printf("\nhis team is %s",p1.team_name);
    printf("\nhis batting average is %f",p1.batting_average);
    getch();
}



7_3.c
 Write a function to enter rollno, marks of the three subject for 3 student and find total obtained by each student


#include<stdio.h>
#include<conio.h>
struct student
{
    int roll_no;
    int mark[2];
};
void add(struct student st[],int a);
void main()
{
    int total,i;
    struct student s[2];
    clrscr();
    printf("enter the mark of three student of three subject respectively\n");
    for(i=0;i<=2;i++)
    {
    scanf("%d",&s[i].mark[0]);
    scanf("%d",&s[i].mark[1]);
    scanf("%d",&s[i].mark[2]);
    }
    add(s,2);
    getch();
}
    void add(struct student st[],int a)
    {
        int total,j;
        printf("total of three students of three subject is respectively\n");
        for(j=0;j<=a;j++)
        {
        total=st[j].mark[0]+st[j].mark[1]+st[j].mark[2];
        printf("\n%d",total);
        }
    }

No comments:

Post a Comment