why am I getting a syntax error in while principal! = -1 #include <stdio.h> int
ID: 3879758 • Letter: W
Question
why am I getting a syntax error in while principal! = -1
#include <stdio.h>
int main()
{
//declare variables for the interest calculator
double principal = 0;
double rate = 0;
int term = 0; //this is a whole number, not decimal
double interest = 0;
printf("%s","Enter the loan principal(-1 to end)");
scanf_s("%lf", &principal);
//loop to calculate the interest as long as principal is valid
while (principal != -1)
printf("%s", "Enter the interest rate (.08") :")"
scanf_s("%lf", &rate);
printf("%s", "Enter the term of the loan in days:");
scanf_s("%d", &term);
//calculate and print the interest
interest = principal * rate * term / 365;
printf("The interest charge is $%3.3f , interest");
printf("%s","Enter the loan principal(-1 to end)");
scanf_s("% lf",&principal);
}
Explanation / Answer
The problem is not with the while statement.
it is with the statement below while
printf("%s", "Enter the interest rate (.08") :")"
Please check this, the statement should end with a semicolon. It appears the statement should be
printf("%s", "Enter the interest rate (.08)");
Please comment below for any doubts
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.