- 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++; } }

29th Jan 2021, 4:01 PM
Yash Makwana
Yash Makwana - avatar
1 ответ
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.
3rd Feb 2021, 7:01 PM
David
David - avatar