Q2157.
#include
int main()
{
double a,b;
char po;
printf("Type in an expression: " );
scanf("%lf%c%lf",&a,&po,&b);
switch(po)
{
case '+':printf("=%.2f\n",a+b);break;
case '-':printf("=%.2f\n",a-b);break;
case '*':printf("=%.2f\n",a*b);break;
case '/':printf("=%.2f\n",a/b);break;
default :printf("Unknown operator\n");
}
}
Q348.
#include
#include
int main()
{
int a;
double b, rate;
printf("Please enter year,capital:");
scanf("%d,%lf", &a, &b);
switch (a)
{
case 1:
rate = 0.0225;
printf("rate = %f, deposit = %f\n", rate, (double)b * (double)pow(1 + rate, a));
break;
case 2:
rate = 0.0243;
printf("rate = %f, deposit = %f\n", rate, (double)b * (double)pow(1 + rate, a));
break;
case 3:
rate = 0.0270;
printf("rate = %f, deposit = %f\n", rate, (double)b * (double)pow(1 + rate, a));
break;
case 5:
rate = 0.0288;
printf("rate = %f, deposit = %f\n", rate, (double)b * (double)pow(1 + rate, a));
break;
case 8:
rate = 0.0300;
printf("rate = %f, deposit = %f\n", rate, (double)b * (double)pow(1 + rate, a));
break;
default :
printf("Error rate!\n");
}
return 0;
}
Q219.
#include
int main()
{
char a;
printf("Press a key and then press Enter:");
scanf("%c", &a);
if ((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z'))
{
printf("It is an English character!\n");
}
else
{
if (a >= 0 && a <= 9)
{
printf("It is a digit character!\n");
}
else
{
if (a == ' ')
{
printf("It is a space character!\n");
}
else
printf("It is other character!\n");
}
}
return 0;
}
Q221.
#include
main()
{
int year, month;
prin