Advertisement
AedenCak3

C program to read an integer from user and output its last and first digit

Nov 15th, 2021
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,F,L;
  5.     printf("Enter a number: ");
  6.     scanf("%d",&n);
  7.  
  8.     L=n%10;
  9.  
  10.     while(n>= 10)
  11.     {
  12.         n=n/10;
  13.     }
  14.  
  15.  
  16.     F=n;
  17.  
  18.     printf("Last Digit :%d\n",L );
  19.     printf("First Digit :%d\n",F);
  20.  
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement