Identify the digits in a given number.

前端 未结 7 729
滥情空心
滥情空心 2020-12-07 03:41

I\'m new to programming, and I\'m stuck at a problem. I want my program to identify the separate digits in a given number, like if I input 4692, it should ident

7条回答
  •  难免孤独
    2020-12-07 03:58

    Haven't written C code in year, but this should work.

    int i = 12345;
    
    while( i > 0 ){
       int nextVal = i % 10;
       printf( "%d", nextVal );
       i = i / 10;
    }
    

提交回复
热议问题