I had written a c.I was using goto statement thus i thought it is fault of the goto statement but when use simple printf() statement and found that it was the fault of the goto but it it fault of the if statement.here is my program
#include <stdio.h>
#include <math.h>
float power(float a,float b);
int main(){//B main
char z;
float x,y;
printf("please,enter the number on which you want to raise \nand the
number by which you want to raise othe number resplectevly:- ");
scanf("%f %f",&x,&y);
printf("%f \n",power(x,y));
fflush(stdin);
printf("do you want to enter the numbers again? y/n:- ");
scanf(" %c",&z);
if(z=='y');
{
printf("y\n");
}
}//B main
float power(float a,float b){//B function power
float d=pow(a,b);
return d;
}//B power power
and here is the output
linuxman@Aspire:~/c programs/a raised to b$ ./a.out
please,enter the number on which you want to raise
and the number by which you want to raise othe number resplectevly:- 4 2
16.000000
do you want to enter the numbers again? y/n:- n
y
linuxman@Aspire:~/c programs/a raised to b$
i had enterd n and even thus it prints y.why is this happening?
noob in programing
Aucun commentaire:
Enregistrer un commentaire