#include int main() { printf("Enter the number: "); char ch = getchar(); int isNegative = 0,gotDecimal = 0;int integerPart = 0,floatPart = 0,div1 = 1,div =1; while( (ch >= '0' && ch <= '9') || ch == '.' || ch == '-' ) { if(ch == '-') { isNegative = 1; } else { if(ch != '.') { if(gotDecimal == 0) { integerPart = integerPart *10 + (ch - '0'); //printf("digit before decimal : %d NUmber : %f \n",(ch - '0') , integerPart); div1 = div1 *10; } if(gotDecimal == 1) { //printf("digit after decimal : %d\n",(ch - '0')); floatPart = floatPart *10 + (ch - '0'); //printf("digit after decimal : %d NUmber : %f \n",(ch - '0') , floatPart); div = div *10; } } if(ch == '.') { gotDecimal = 1; } } ch = getchar(); } //div1 = div1 /10;div =div/10; printf("The number is intergerPart : %d floatPart : %d\n",integerPart,floatPart); floatPart = floatPart * 2; if(floatPart > div) { integerPart = integerPart * 2 + 1; floatPart = floatPart - div; } else { integerPart = integerPart * 2 ; } div = div /10; if(integerPart < div1) div1 = div1/10; printf("Twice the number: intergerPart : %d floatPart : %d\n",integerPart,floatPart); printf("Now printing twice the input number using putchar: "); if(isNegative == 1) putchar('-'); int n = integerPart; while( n > 0) { int digit = n / div1; n = n % div1; div1 = div1 /10; putchar(digit + '0'); } if(gotDecimal == 1) { putchar('.'); n = floatPart; while( n > 0) { int digit = n / div; n = n % div; div = div /10; putchar(digit + '0'); } } printf("\n"); return 0; }