C Program To Create Records

The program below holds the name and earnings of an employee. A loop is set for only three employees. You can specify any number of persons in your program.

The predecessor directives come first, one to aid 'clrscr' in the program. Basic rule of c++ programming.

The records will be stored in a structure called 'struct gra'. Declarations are made within this structure. These are 'count' and 'earn' being declared as integers. So is 'name' declared as a character 'char' with the number of characters or letters it should allow [30].

#include <conio.h>
#include<stdio.h>
struct gra
{
   int count, earn;
   char name[30];
    }
      
      loop[3];
      void main()
       {
       clrscr;
           
            for (int i=0;i<3;i++)
            {
            printf("Enter the employee number: ");
            scanf("%d",&loop[i].count);
            printf("\nEnter Employees's name: ");
            scanf("%s",&loop[i].name);
            printf("\nEnter the earnings: ");
            scanf("%d",&loop[i].earn);
            }
      for (i=0;i<3;i++)
      {
         printf("%4d",loop[i].count);
         printf("%8s",loop[i].name);
         printf("%4d",loop[i].earn);
       }
 getch();
}

Author:

Tech blogger, SEO expert, cryptocurrency enthusiast, and freelancer are the terms that describe me. I'll rather write a thousand words than speak hundred words, and that describes my passion as a content creator.