Each Sunday, a newspaper agency sells x copies of a certain newspaper for Rs.a per copy. The cost to the agency of each newspaper is Rs.b . The agency pays a fixed cost for storage, delivery and so on of Rs.100 per Sunday. The newspaper agency wants to calculate the profit obtained on sundays. Can you please help them out by writing a C program to compute the profit given x, a and b.
Input Format:
Input consists of 3 integers --- x, a and b. X is the number of copies sold, a is the cost per copy and b is the cost the agency spends per copy.
Output Format:
Refer Sample Input and Output for exact formatting specifications.
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Enter the number of copies sold
1000
Enter the cost of 1 copy of the newspaper
2
Enter the cost spent by the agency on 1 copy of the newspaper
1
The profit obtained is Rs.900
Code:
#include<stdio.h> int main(){ int n,c,s,o=0; printf("Enter the number of copies sold\n"); scanf("%d",&n); printf("Enter the cost of 1 copy of the newspaper\n"); scanf("%d",&c); printf("Enter the cost spent by the agency on 1 copy of the newspaper\n"); scanf("%d",&s); o=((n*c)-(n*s))-100; printf("The profit obtained is Rs.%d",o); return 0; }
o=((n (c s)-100));<---how to solve this Ans 900
ReplyDeleteo=((n*c)-(n*s))-100;
o=((n (c s)-100));<---how to solve this Ans 900
ReplyDeleteo=((n*c)-(n*s))-100;
why -100
ReplyDeleteAs the agency pays a fixed cost of Rs100.(Refer question).
DeleteThis comment has been removed by the author.
ReplyDeletex=int(input())
Deletea=int(input())
b=int(input())
sp=x*a
cp=x*b
profit=sp-cp-100
print("The profit obtained is Rs.",profit)
tq
ReplyDelete