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 Respuestas
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;
}