Showing posts with label Record. Show all posts
Showing posts with label Record. Show all posts

C Program To Make Employee Payment Record Using Structure

How to write a C Program To Make Employee Payment Record Using Structure in C Programming Language ?


Solution For C Program :

/*C Program To Make Employee Payment Record Using Structure.*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
struct employee
    {
    int bs,att;
    char name[10];
    };
struct employee emp[10];
void main()
{
int i;
float ded,da,hra,net,gross,sal;
clrscr();
for(i=1;i<4;i++)
    {
    printf("enter the name of %d employee: ",i);
    scanf("%s",emp[i].name);
    printf("enter the attendence of preset month = ");
    scanf("%d",&emp[i].att);
    printf("enter the basic salary =");
    scanf("%d",&emp[i].bs);
    }

printf("\n\ndata stored are :\n");
for(i=1;i<4;i++)
    {
    printf("Name of %d employee: %s\n",i,emp[i].name);
    sal=(emp[i].bs/30)*emp[i].att;
    da=sal*0.1;
    hra=sal*0.2;
    gross=sal+da+hra;
    ded=gross*0.1;
    net=gross-ded;
    printf("Gross salary =%f\n",gross);
    printf("Net salary =%f\n",net);
    }
getch();
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Store Students Record In A Text File

How to write a C Program To Store Students Record In A Text File in C Programming Language ?


Solution For C Program :

/*C Program To Store Students Record In A Text File.*/


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
    FILE *fp;
    char another='y';
    int marks1,marks2,marks3,marks4,marks5,role;
    char name[20];
    clrscr();

    fp=fopen("Students.txt","w");
    if(fp==NULL)
    {
        puts("Cannot open file");
        exit(1);
    }
       fprintf(fp,"Role No.\tNAME\t  PHYSICS  CHEMISTRY  MATHS  S.S.T  ENGLISH\n");
    while(another=='y')
    {
        printf("\nEnter name :");
        scanf("%s",&name);
        printf("Enter your Role No.:");
        scanf("%d",&role);
        printf("Enter marks in Physics:");
        scanf("%d",&marks1);
        printf("Enter marks in Chemistry:");
        scanf("%d",&marks2);
        printf("Enter marks in Mathematics:");
        scanf("%d",&marks3);
        printf("Enter marks in Social Science:");
        scanf("%d",&marks4);
        printf("Enter marks in English:");
        scanf("%d",&marks5);
        fprintf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%d\n",role, name, marks1,marks2,marks3,marks4,marks5);
        printf("Add another record (y/n): ");
        fflush(stdin);
        another=getche();
    }
    fclose(fp);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program To Store Students Record Using Structure

How to write a C Program To Store Students Record Using Structure in C Programming Language ?


Solution For C Program :

/*C Program To Store Students Record Using Structure.*/


#include<stdio.h>
#include<conio.h>
struct student{
    int role_no;
    char name[20];
    int marks;
    char course[20];
    };
struct student stud[10];
void main()
{
int i;
clrscr();
printf("enter the students record one by one.\n");
for(i=0;i<3;i++)
    {
    printf("Enter the role no= ");
    scanf("%d",&stud[i].role_no);
    printf("Enter the name of student: ");
    scanf("%s",&stud[i].name);
    printf("Enter the marks obtained= ");
    scanf("%d",&stud[i].marks);
    printf("Enter the course: ");
    scanf("%s",&stud[i].course);

    }
    clrscr();
printf("---------STUDENTS RECORD FILE-------\n");
for(i=0;i<3;i++)
    {
    printf("\nROLE NO.: %d",stud[i].role_no);
    printf("\nNAME: %s",stud[i].name);
    printf("\nCOURSE: %s",stud[i].course);
    printf("\nMARKS OBTAINED: %d",stud[i].marks);
    printf("\n----------------------------------\n\n");
    }
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable