In this article I would like to share with you a very simple program that I wrote using C# that will ask the user to give a number and then our program will compute the square and cube equivalent of the number based on the given number by our user.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace square_cube
{
class square_cube
{
/* Program : Square and Cube Numbers */
/* Author : Mr. Jake R. Pomperada, MAED-IT */
/* Date : Noverber 24, 2016 Thursday 11:20 AM */
/* Tools : C# */
static void Main(string[] args)
{
int num = 0,square=0,cube=0;
Console.Write("\n\n");
Console.Write(" ===== SQUARE AND CUBE NUMBERS ===== ");
Console.Write("\n\n");
Console.Write("Give a Number : ");
num= int.Parse(Console.ReadLine());
Console.Write("\n");
Console.Write("===== DISPLAY RESULTS ===== ");
Console.Write("\n\n");
while (num != 0)
{
square = num * num;
cube = num * num * num;
Console.Write("The Square of {0} is {1} and Cube of {0} is {2}.",num, square, cube);
break;
}
Console.Write("\n\n");
Console.Write(" End of Program ");
Console.Write("\n\n");
Console.ReadLine();
}
}
}
No comments:
Post a Comment