0

Write c program

Given a situation, you're going to stationary shop and buying five long size unruled classmate notebooks for writing notes for five different subjects. You paid Rs.500 to the shopkeeper for which the shopkeeper gave back Rs.25 back to you as change.  Write a C program to find the cost of each notebook that you've bought. Give 500 as input to the system using scanf statement.

21st Oct 2021, 9:08 AM
J SAI JAI BHARGAV
J SAI JAI BHARGAV - avatar
6 Answers
0
structure is the best concept to implement this requirement struct shop { char book[50]; int price; }; #include<stdio.h> void main() { struct shop s; printf(”Enter book name :”); scanf(”%s”, s.book); printf(”Enter available amount :); scanf(“%d”,&s.price); printf(”Amount in pocket : %d\n”, s.price); printf(”Book = %s\n”, s.book); s.price = s.price - 475; printf(”Available amount : %d\n”, s.price); }
22nd Oct 2021, 7:37 AM
sree harsha
sree harsha - avatar
+ 6
Written. Now what's your doubt ?
21st Oct 2021, 9:15 AM
Arsenic
Arsenic - avatar
+ 5
You need to declare paid as input variable. int paid; scanf("%d",&paid);
21st Oct 2021, 11:01 AM
Simba
Simba - avatar
+ 3
Kindly share your attempt!!
21st Oct 2021, 10:07 AM
Saurabh
Saurabh - avatar
+ 3
Everything seems to be right in your code BHARGAV , What's your problem?!
21st Oct 2021, 10:37 AM
Saurabh
Saurabh - avatar
+ 2
#include <stdio.h> int main() { int paid=500,change=25,cost=0,singlebook=0; cost=paid-change; singlebook =cost/5; printf("%d",singlebook); return 0; }
21st Oct 2021, 10:17 AM
J SAI JAI BHARGAV
J SAI JAI BHARGAV - avatar