Skip to main content

Structure within Function in C

#include<stdio.h>
 #include<conio.h>
   struct stores
    {
      char name[20];
      float price;
      int quantity;
      };
      struct stores update(struct stores product, float p, int q)
      {
	product.price+=p;
	product.quantity+=q;
	return(product);
      }
      float mul(struct stores stock)
      {
       return(stock.price*stock.quantity);
      }
    void main(void)
     {
       clrscr();
       float p_inc,value;
       int q_inc;
       static struct stores item={"XYZ",25.75,12};
       printf("\n Input inc values:\n");
       printf("\n Price inc  and Quantity inc\n\n");
       scanf("%f %d",&p_inc,&q_inc);
       item=update(item,p_inc,q_inc);
       printf("Update values of item\n\n");
       printf("name     :%s\n",item.name);
       printf("Price     :%f\n",item.price);
       printf("Quantity   :%d\n",item.quantity);
       value=mul(item);
       printf("\n values of the item =%f\n",value);
       getch();
     }

Spread the love

Mashkawat Ahsan

I am Mashkawat Ahsan. Wikipedian, Mozillian, tech activist, art lover. Thank you for visiting.

Leave a Reply

Your email address will not be published. Required fields are marked *