C Program to Find First and Last Digit of a Number

Опубликовано: 12 Март 2025
на канале: Technotip
49,023
488

http://technotip.com/6766/c-program-t...

Write a C program to find first and last digit of the user input number, without using looping.

if num = 123;

count = log10(num); // count = 2;

first = num / pow(10, count); // first = 1;

last = num % 10; // last = 3;


Both pow() and log10() are built-in methods present in header file math.h So we include that library file at the beginning of our C program source code.

C Programming Interview / Viva Q&A List
http://technotip.com/6378/c-programmi...

C Programming: Beginner To Advance To Expert
http://technotip.com/6086/c-programmi...