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();
}



Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:


HTML Link Code:

BB (forum) link code:

Comments