Please write the program in C LANGUAGE. Morover, implement the use of \"struct.\
ID: 3733963 • Letter: P
Question
Please write the program in C LANGUAGE. Morover, implement the use of "struct." Finally, please provide comments and documentation to aid in understanding of why you did what you did. Thank you so much!
Explanation / Answer
#include<stdio.h>
#include<conio.h>
struct p_vital_info
{
float temperature;
int systolic_pressure;
int diastolic_pressure;
};
struct p_activity_info
{
int step_count;
int sleep_hours;
};
void main()
{
struct p_vital_info pv[50];
struct p_activity_info pa[50];
int choice,no,i;
clrscr();
printf("Please enter the number for the desired action (1,2,3): ");
scanf("%d",&choice);
if(choice==1)
{
printf("Enter total number of records to insert ");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("Enter the temperature: ");
scanf("%f",&pv[i].temperature);
printf("Enter the systolic pressure: ");
scanf("%d",&pv[i].systolic_pressure);
printf("Enter the diastolic pressure: ");
scanf("%d",&pv[i].diastolic_pressure);
}
}
else if(choice==2)
{
printf("Enter total number of records to insert ");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("Enter the temperature: ");
scanf("%f",&pa[i].sleep_hours);
printf("Enter the systolic pressure: ");
scanf("%d",&pa[i].step_count);
}
}
printf("total number of records are ");
for(i=0;i<no;i++)
{
printf("the temperature is %f ",pv[i].temperature);
printf("the systolic pressure is %d ",pv[i].systolic_pressure);
printf("Enter the diastolic pressure is %d ",pv[i].diastolic_pressure);
}
getch();
}