Print first digit of a number -
#include <stdio.h> int main() { int n; printf("Enter the number "); scanf("%d",&n); while (n>10) { n/=10; } printf("The first digit is %d",n); return 0; }
Output -
Enter the number 1234 The first digit is 1
#include <stdio.h> int main() { int n; printf("Enter the number "); scanf("%d",&n); while (n>10) { n/=10; } printf("The first digit is %d",n); return 0; }
Enter the number 1234 The first digit is 1
0 Comments