Advertisement
remote87

Four-digit number

Aug 29th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _06FourDigitNumber
  8. {
  9.     class FourDigitNumber
  10.     {
  11.         static void Main()
  12.         {
  13.             Console.Write("Enter a four-digit number: ");
  14.             int a = Console.Read() - '0';
  15.             int b = Console.Read() - '0';
  16.             int c = Console.Read() - '0';
  17.             int d = Console.Read() - '0';
  18.             Console.WriteLine("Sum of numbers: {0}", a + b + c + d);
  19.             Console.WriteLine("Reversed order: {0}{1}{2}{3}", d, c, b, a);
  20.             Console.WriteLine("Last digit in front: {0}{1}{2}{3}", d, a, b, c);
  21.             Console.WriteLine("Second and third digit exchanged: {0}{1}{2}{3}", a, c, b, d);          
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement