Answer to Question #306881 in C for bhuvaneshwar

Question #306881

Mr Kishan owns a supermarket and he has stored the price of all items in an array. However he wants to now increase the price of all items by Rs 5. Write a program using functions which increments the price of all items by Rs 5 and displays the updated list.


1
Expert's answer
2022-03-07T07:11:11-0500
#include <stdio.h>

#define SIZE 324

char *item_name[SIZE];
int item_price[SIZE];

void inc(int delta) {
  for (int i = 0; i < SIZE; i++) {
    item_price[i] += delta;
  }
}

void display() {
  for (int i = 0; i < SIZE; i++) {
    printf("%s: %d\n", item_name[i], item_price[i]);
  }
}

int main(void) {
  inc(5);
  display();
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS