请大家帮我看看这个程序错在哪?

来源:百度知道 编辑:UC知道 时间:2024/06/15 09:45:44
c语言的题目

{

int num,ph,oph;
char R,C,I,code;
double pay,paya,payb;
unsigned char Y=156;

printf("The code of R means residential use, the code of C means commercial use and the code of I means industrial use.\n");
printf("Please type in your code:\n");
scanf("%c", &code);

if(code=R)
{printf("\nPlease type in your consumption figures in whole numbers of kilowatt-hours : ");
scanf("%d",&num);
pay=4.00+0.03*num;
}
else
if(code=C)
{printf("\nPlease type in your consumption figures in whole numbers of kilowatt-hours : ");
scanf("%d",&num);
if(num<=1000)
pay=40.00;
else
if(num>1000)
pay=(num-1000)*0.025+40.00;
}
else
if(code=I)
{

注意几个判断的地方:
if(code == 'R')
else if(code == 'C')
else if(code == 'I')

#include <stdio.h>

void main()
{

int num, ph, oph;
char R, C, I, code;
double pay, paya, payb;
unsigned char Y = 156;

printf("The code of R means residential use, the code of C means commercial use and the code of I means industrial use.\n");
printf("Please type in your code:\n");
scanf("%c", &code);

if(code == 'R')
{
printf("\nPlease type in your consumption figures in whole numbers of kilowatt-hours : ");
scanf("%d",&num);

pay=4.00+0.03*num;
}
else if(code == 'C')
{
printf("\nPlease type in your consumption figures in whole numbers of kilowatt-hours : ");
scanf("%d",&num);

if(nu