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


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. #include <stdio.h>
  2.  
  3. main()
  4. {
  5. int num, last ;
  6. printf("Enter any number : ");
  7. scanf("%d", &num);
  8.  
  9. last = num%10;
  10. printf("The last digit of entered number: %d\n", last);
  11.  
  12. while(num>=10)
  13. {
  14. num = num/10;
  15. }
  16.  
  17. printf("The first digit of entered number: %d\n", num);
  18. }
  19.  

Result

C language

     





Related Topics




Popular Posts