0

can yall help me with a simple solution in c for this problem??

• The first 2 minutes is 100$ • Every additional 10 seconds is 5$ Question: Write a program that is going to read n phone call times (in seconds). And then, the program will calculate the total amount collected from all users. Input specification You will be given an integer number (n). Then, the following n lines will contain the talk time (in seconds) for n people. Output specification Calculate and show the amount due from the user.

2nd Feb 2020, 10:58 AM
cherry blossom
3 ответов
+ 1
use <n not <=n
2nd Feb 2020, 11:58 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
Can you show us your attempt ?
2nd Feb 2020, 11:06 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
int main() { int n,t,price,tot=0,i; printf("Enter the number of phone calls made: "); scanf("%d",&n); for(i=0;i<=n;i++) { printf("Enter the seconds for each call:"); scanf("%d",&t); if (t<=120) price=100; else price=100 + ((t-120)/10)*5; tot=tot+price; } printf("The total amount spent is %d leke",tot); return 0; }
2nd Feb 2020, 11:08 AM
cherry blossom