Skip to main content
C program to find first and last digit in the given number
 
#include<stdio.h>
int main()
{
    int n,i,num;
    printf("enter the number \n\n");
    scanf("%d",&n);
    int first,last;
    num=n;
    last=n%10;
    while(n>9)
    {
        n=n/10;
    }
    first=n;
    printf("\nthe first and last number in %d is:%d and %d\n",num,first,last);
}
Output:
 
 
 
 
 
 
 
  
 
 
 
 
 
Comments
Post a Comment