Bill Calculator
#include <stdio.h>
int main(){
int amount;
int sum=0; //most important to declare outside the loop-----
while(1){
printf("Enter the amount:\n");
scanf("%d",&amount);
if(amount!=0){
sum=sum+amount;
printf("Order total so far is: %d\n",sum);
continue;
}
else{
printf("Order total is: %d\n",sum);
printf("Have a nice day ahead\n");
break;
}
}
return 0;
}
Comments
Post a Comment