Computer Science, asked by alsoong3, 2 months ago

Write a program to calculate and display the cube of a number till a given number (using for loop).​

Answers

Answered by Lokesh1429
1

Answer:

In Java,Python,C++

Explanation:

Java;

import java.util.Scanner;

public class FindingCube {

  public static void main(String args[]){

     int n = 5;

     System.out.println("Enter a number ::");

     Scanner sc = new Scanner(System.in);

     int num = sc.nextInt();

     System.out.println("Cube of the given number is "+(num*num*num));

  }

}

Python;

# Python program to calculate cube of given number

 

# take input a number from user

num = int(input("Enter an any number: "))

 

# calculate cube using * operator

cb = num*num*num

 

# display result

print("Cube of {0} is {1} ".format(num, cb))

C++;

// C++ program to display the cube of the numbers upto a given integer

#include <iostream>

using namespace std;

int main()

{

 int i, n, cube;

 cout << "Input the number of terms : ";

 cin >> n;

 for (i = 1; i <= n; i++){

   cube = i * i * i;

   cout << "Number is: " << i << " and its cube is: " << cube << endl;

 }

}

Answered by yuktashree26
0

SIR.SIKHAYA.NA.TOH.KYU.CHAHIYE.¯\_ಠ_ಠ_/¯

Similar questions