77.2k views
5 votes
Write a program that accepts a number as input, and prints just the decimal portion. Your program must account for negative numbers.

Sample Run
Enter a number: 15.789
Sample Output
0.789

1 Answer

4 votes

Answer:here I write code

Step-by-step explanation:

#include <stdio.h>

int main(void) {

char x[]="" ;

int a,b,Flag=0;

gets(x);

b=sizeof(x);

for(a=0; a<b; a++){

if(x[a]=='.')

Flag=1;

if(Flag==1)

printf("%c",x[a]);

}

return 0;

}

User Samiullah Khan
by
6.0k points