PPS Practical 50

PPS Practical 50
  • Aim: Define a structure type struct personal that would contain person name, date of joining and salary using this structure to read this information of 5 people and print the same on screen.
  • Code:
    //For turbo C++ remove below comments
    #include <stdio.h>
    //#include<conio.h>
    struct person
    {
        char person_name[100];
        char join_date[100];
        float salary;
    };
    struct person p[5];
    void main()
    {
    	//clrscr();
        int i;
        for (i = 0; i < 5; i++){
            printf("Enter Name of the person %d:- ", i+1);
            scanf("%s", &p[i].person_name);
            printf("Enter Joining Date of the person %d:- ", i+1);
            scanf("%s", &p[i].join_date);
            printf("Enter Salary of the person %d:- ", i+1);
            scanf("%f", &p[i].salary);
        }
        for (i = 0; i < 5; i++)
        {
            printf("\nName of the person %d:- %s\n", i+1, p[i].person_name);
            printf("Joining Date of the person %d:- %s\n", i+1, p[i].join_date);
            printf("Salary of the person %d:- %0.2f\n", i+1, p[i].salary);
        }
        //getch();
    }

Comments