C Program to Print First Digit of Number using For Loop
Write a Program to Print First Digit of Number using For Loop
// C Program to Print First Digit of Number using For Loop #include <stdio.h> int main() { int n, remainder; printf("Enter the Number :--> "); scanf("%d", &n); for(; n > 0; ) { remainder = n % 10; n = n / 10; } printf("The first digit of the number is : %d",remainder); return 0; }
Output:
Enter the Number :--> 65
The first digit of the number is : 6