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.
#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;
}
Comments
Leave a comment