c# - Write a program which will input a 4 digit number from the user and then print the first and 2nd last digit of the number? -


write program input 4 digit number user , print first , 2nd last digit of number .... can reverse 4 numbers can't this..

assuming entered number 4 digit number.

class program {     static void main(string[] args)     {         int num, sum = 0, r,pos = 0;          console.writeline("enter number : ");         num = int.parse(console.readline());          while (num != 0)         {              pos++;             r = num % 10;             num = num / 10;              if(pos == 0)||(pos==2){                 console.writeline("digit at"+ pos + "is : "+r);             }         }                    console.readline();     } } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -