Q:

Write a program in C# Sharp to display the cube of the number up to given an integer

0

Write a program in C# Sharp to display the cube of the number up to given an integer

Sample Output:

Display the cube of the number:                                                                               
---------------------------------                                                                             
                                                                                                              
Input number of terms : 5                                                                                     
Number is : 1 and cube of the 1 is :1                                                                         
Number is : 2 and cube of the 2 is :8                                                                         
Number is : 3 and cube of the 3 is :27                                                                        
Number is : 4 and cube of the 4 is :64                                                                        
Number is : 5 and cube of the 5 is :125

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;  
public class Exercise5 
{  
    public static void Main() 
 {
    int i,ctr;
	Console.Write("\n\n");
    Console.Write("Display the cube of the number:\n");
    Console.Write("---------------------------------");
    Console.Write("\n\n");	
	
    Console.Write("Input number of terms : ");
    ctr= Convert.ToInt32(Console.ReadLine());	
    for(i=1;i<=ctr;i++)
    {
	 Console.Write("Number is : {0} and cube of the {1} is :{2} \n",i,i, (i*i*i));     
    }
  }	
 }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now