You are on page 1of 8

DEPARTMENT OF CSE

Name of the Student S.PRAVEEN


Roll Number 18R21A05B0
Name of the Lab DATA STRUCTURES LAB
Week No WEEK - I

PROBLEM STATEMENT:

1.Write a C program to read the employee details employee number ,employee name , basic salary,
hra , and da of employee using structures and print emp number ,emp name and gross salary of
employee.

PROGRAM:
#include <stdio.h>
#include <stdlib.h>

struct employee
{
int enumb;
char ename[20];
int basic;
int hra;
int da;
float gross;

}e1;
int main()
{
printf("Enter employee name\n");
scanf("%s",e1.ename);
printf("Enter employee number\n");
scanf("%d",&e1.enumb);
printf("Enter basic salary hra and da");
scanf("%d%d%d",&e1.basic,&e1.hra,&e1.da);
e1.gross=e1.basic+(e1.basic*e1.hra/100)+(e1.basic*e1.da/100);

printf("%d\n",e1.enumb);
printf("%s\n",e1.ename);
printf("Gross salary = %f\n",e1.gross);
}

TEST CASE 1:
1.1
DEPARTMENT OF CSE
Employee test case one:

TEST CASE 2:
DEPARTMENT OF CSE

TEST CASE 3:

2.PROBLEM STATEMENT:

2.Write a C program to read real and imaginary parts of a complex numbers using structures and
perform the multiplication operations on complex numbers.

PROGRAM:
#include <stdio.h>
#include <stdlib.h>
int mul();
struct numb
{
float real,imag;
}c1,c2,c3;
int main()
{
printf("Enter number1 real and imag parts\n");
scanf("%f%f",&c1.real,&c1.imag);
printf("Enter number2 real and imag parts\n");
DEPARTMENT OF CSE
scanf("%f%f",&c2.real,&c2.imag);
mul();
}
int mul()
{
c3.real=(c1.real*c2.real)-(c1.imag*c2.imag);
c3.imag=(c1.real*c2.imag)-(c1.imag*c2.real);
printf("Result = %f + i %f",c3.real,c3.imag);
}

TEST CASE 1:

TEST CASE 2:
DEPARTMENT OF CSE

TEST CASE 3:

3.PROBLEM STATEMENT:
3.Write a C program to read time in hours, minutes, seconds, using structures and perform addition of
two time periods.

PROGRAM:
#include <stdio.h>
#include <stdlib.h>
DEPARTMENT OF CSE
void add();
struct time
{
int hr,min,sec;
}t1,t2,t3;

void add()
{

t3.sec=t1.sec+t2.sec;
t3.min=t1.min+t2.min;
t3.hr=t1.hr+t2.hr;
if(t3.sec>=60)
{
t3.min++;
t3.sec=t3.sec-60;
}
if(t3.min>=60)
{
t3.hr++;
t3.min=t3.min-60;
}
printf("final time = %d : %d : %d",t3.hr,t3.min,t3.sec);
}
int main()
{
printf("enter time1 hr min sec");
scanf("%d%d%d",&t1.hr,&t1.min,&t1.sec);
printf("enter time2 hr min sec");
scanf("%d%d%d",&t2.hr,&t2.min,&t2.sec);
add();
}

TEST CASE 1:
DEPARTMENT OF CSE

TEST CASE 2:

TEST CASE 3:
DEPARTMENT OF CSE

You might also like