A program that list the number from 0 to 25, their square, square roots,fourth power, and fourth root. The output should be in a neat five column format.
1
Expert's answer
2012-07-20T11:16:28-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Question12113 { class Program { & static void Main(string[] args) & { Console.WriteLine("___________________________________________________________"); Console.WriteLine("|Number | square | square root | fourth power | fourth root|"); Console.WriteLine("|----------------------------------------------------------|"); for (int i = 0; i <= 25; i++) { Console.Write("|{0,6:D} |", i); Console.Write("{0,7:D} |", i * i); Console.Write("{0,12:G4} |", Math.Sqrt(i)); Console.Write("{0,13:G0} |", Math.Pow(i, 4)); Console.Write("{0,12:G6}|\n", Math.Pow(i, 1.0 / 4.0)); Console.WriteLine("|----------------------------------------------------------|"); } Console.ReadKey(); & } } }
Comments