Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to update stock price using structure pointer

Posted By: Isabella Campbell     Category: C Programming     Views: 7230

Write a program to update stock price using structure pointer.

Code for Program to update stock price using structure pointer in C Programming

#include <stdio.h>
#include <conio.h>

struct stores
{
   char name[20];
   float price;
   int quantity;
};

float mul(struct stores *stock);
void update(struct stores*, float, int);

void main()
{
   float p_incre, value;
   int q_incre;

   struct stores item = {"XYZ", 25.75, 12};
   struct stores *ptr = &item;

   clrscr();

   printf("\nInput increment values : ");
   printf("Price increment and quantity increment\n");
   scanf("%f %d", &p_incre, &q_incre);

   /**********************************************/
update(&item, p_incre, q_incre); /**********************************************/
printf("Updated values of item \n\n"); printf("Name : %s\n", ptr->name); printf("Price : %f\n", ptr->price); printf("Quantity : %d\n", ptr->quantity); /**********************************************/
value = mul(&item); /**********************************************/
printf("\nValue of the item = %f\n", value); getch(); } void update(struct stores *product, float p, int q) { product -> price += p; product -> quantity += q; } float mul(struct stores *stock) { return(stock->price * stock ->quantity); } /*************** Input Output ***************
Input increment values : Price increment and quantity increment
12
22
Updated values of item

Name : XYZ
Price : 37.750000
Quantity : 34

Value of the item = 1283.500000

**************** ***************/
  
Share: 


Didn't find what you were looking for? Find more on Program to update stock price using structure pointer Or get search suggestion and latest updates.

Isabella Campbell
Isabella Campbell author of Program to update stock price using structure pointer is from Toronto, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!