C Program to print First Digit of Number using While loop
Write C Program to print First Digit of Number using While loop
//Write a program to print first digit of a number #include <stdio.h> int main() { int n, remainder; printf("Enter the Number :--> "); scanf("%d", &n); while(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