// Q. Find out the simple interest.
#include <stdio.h>
#include <math.h>
int main()
{
int principal, rate, time;
printf("principaln");
scanf("% d", &principal);
printf("raten");
scanf("% d", &rate);
printf("timen");
scanf("% d", &time);
printf("Simple interest is %d", principal * rate * time / 100);
return 0;
}
要使scanf
正常工作,您需要删除格式字符串中%和d之间的空格:% d
.
#include <stdio.h>
#include <math.h>
int main()
{
int principal, rate, time;
printf("principaln");
scanf("%d", &principal);
printf("raten");
scanf("%d", &rate);
printf("timen");
scanf("%d", &time);
printf("Simple interest is %d", principal * rate * time / 100);
return 0;
}
同样,程序不能在编译期间请求输入。它只会在运行时请求输入。