Write C program to find first and last digit of any number

Introduction

Write C program to find first and last digit of any number

#include <stdio.h>
 
main()
{
    int num, last ;
    printf("Enter any number : ");
    scanf("%d", &num);
 
    last = num%10;
    printf("The last digit of entered number: %d\n", last);
 
    while(num>=10)
    {
        num = num/10;
    }
 
    printf("The first digit of entered number: %d\n", num);
}

Result

Write C program to find first and last digit of any number
Write C program to find first and last digit of any number

Leave a Comment