Define a structure called Item with members : Item_code,Item_name, Price. Create an array of five Items. Create a function which accepts the Item array and modifies each element with an increase of 10% in the price.
CODING:#include<stdio.h>
#include<conio.h>
struct in
{
int cod;
char name[10];
int p;
}s[3];
void input(struct in up[],int n)
{
int i;
for(i=1;i<=n;i++)
{
printf("%d ITEM CODE:",i);
scanf("%d",&up[i].cod);
printf("ITEM NAME:");
scanf("%s",up[i].name);
printf("ITEM PRICE:");
scanf("%d",&up[i].p);
}
}
void output(struct in up[],int n)
{
int i;
for(i=1;i<=n;i++)
{
printf("\n%d ITEM CODE:%d",i,up[i].cod);
printf("\nITEM NAME:%s",up[i].name);
printf("\nITEM PRICE:%d",up[i].p *10/100+up[i].p);
}
}
void main()
{
int i;
clrscr();
input(s,3);
output(s,3);
getch();
}
Comments
Post a Comment