This is my code C++ for my assignment. Please help me to convert it to C code. Thank you!
#include <iostream>
using namespace std;
float f1(float a){
float s;
if (a<250)
s=a*0.11;
else
s=250*0.11+(a-250)*0.17;
return s;
& }
float f2(float a){
& return f1(a)*1.1;
& }
int main(void)
{
float a;
cout<<"enter the number of kilowatt hours consumed : ";
cin>>a;
cout<<"total amount: "<<f2(a)<<endl;
system ("PAUSE");
}
See more: C
#include <stdio.h>
#include <stdlib.h>
float f1(float a)
{
float s;
if (a < 250)
s = a * 0.11;
else
s = 250 * 0.11 + (a - 250) * 0.17;
return s;
}
float f2(float a)
{
return f1(a) * 1.1;
}
int main(void)
{
float a;
printf("enter the number of kilowatt hours consumed : ");
scanf("%f", &a);
printf("total amount: %f\n", f2(a));
system ("PAUSE");
}
Comments
Leave a comment