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.
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);
}
+ 6
Written.
Now what's your doubt ?
+ 5
You need to declare paid as input variable.
int paid;
scanf("%d",&paid);
+ 3
Kindly share your attempt!!
+ 3
Everything seems to be right in your code BHARGAV , What's your problem?!
+ 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;
}