0% found this document useful (0 votes)
0 views

Experiment No.9

Uploaded by

sujalkamble1610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Experiment No.9

Uploaded by

sujalkamble1610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment No.

9
Objective: Write a C program to create Employee record for 2
Employees by using runtime(Variables are name, id , salary)
Code:

#include<stdio.h>

#include<string.h>

struct Employee

char name[50];

int id;

float salary;

};

void main()

struct Employee emp[2];

int i;

printf("Enter the details of the employee :\n");

for(i=0;i<2;i++)

printf("Enter the name of %d Employee :",i+1);

scanf("%s",&emp[i].name);

printf("Enter the ID Of %d Employee :",i+1);

scanf("%d",&emp[i].id);
printf("Enter the salary of %d Employye :",i+1);

scanf("%f",&emp[i].salary);

for(i=0;i<2;i++)

printf("\nThe Details of the %d employee are : \n",i+1);

printf("Name : %s\n",emp[i].name);

printf("ID : %d\n",emp[i].id);

printf("salary : %f\n",emp[i].salary);

Output Window:
2) Write A C program to create a student record for only one
student by using array within a structure(Consider runtime , the
variable are(name, roll no, marks for five subjects)

Code:

#include<stdio.h>

#include<conio.h>

#include<string.h>

struct student

char name[50];

int rollno;

int marks[5];

};

void main()

struct student S;

int i;

clrscr();

printf("Enter name and roll no :\n");

scanf("%s %d",&S.name,&S.rollno);
printf("Enter marks for 5 subject:\n");

for(i=0;i<=4;i++)

scanf("%d",&S.marks[i]);

} printf("Name:%s\n",S.name);

printf("Rollno:%d\n",S.rollno);

printf("Marks of 5 Subject are:\n");

for(i=0;i<=4;i++)

printf("\nSubject %d %d\n",i+1,S.marks[i]);

Output window:

You might also like