- 1
Please give me a error solution in this program
#include<stdio.h> void getdecimal(int); void getfractional(float); int main() { float f; float frac; printf("Enter a no.:"); scanf("%f",&f); dec=(int)f; frac=f-dec; printf("Decimal part is:%d\nFractional part is:%f\n",dec,frac); getdecimal(dec); printf("."); getfractional(frac); return 0; } void getdecimal(int d) { int r; if(d!=0) { r=d%2; d=d/2; getdecimal("%d",r); printf("%d",r); } } void getfractional(float f) { in count=0; while(count!=6) { f*=2; printf("%d",(int)f); f=f-(int)f; count++; } }
1 Antwort
0
The variable "dec" has no type. It should be:
Int dec = (int)f;
In the getdecimal recursion you have to pass r as argument, without %d.
Also, in getfractional, the int type of count is missing the t.