C program to store and display records of N products using union.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define N 5
void dummy(float *a)
{
float b=*a; 
//perform some floating access
dummy (&b); 
//calling a floating point function
}
union product{
int pid;
char pname[20] , mfd[11], sname[20];
float price;
};
void main() {
int i;
union product p[N];
for (i=0;i<N;i++){
clrscr();
printf("Enter %d product's price:-\n",i+1);
scanf("%f",&p[i].price);
getch();
}
for (i=0;i<N;i++) {
clrscr();
printf("\nPrice of %d product = %f \n",i+1,p[i].price);
getch();
}
}

No comments:

Post a Comment