Ticker

6/recent/ticker-posts

Print first digit of a number Program



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

Post a Comment

0 Comments