Answer to Question #261863 in C for Amraj

Question #261863

Write a program in C to display the cube of the number up to given an integer. Go to the editor


Test Data :


Input number of terms : 5


Expected Output :


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

1
Expert's answer
2021-11-09T10:21:27-0500
#include<stdio.h>


int main(){
	printf("Enter a number:\n");
	int n;
	scanf("%d", &n);
	int i;
	for(i=1; i<=n; i++){
		printf("Number is : %d and cube of the %d is : %d\n", i, i, (i*i*i));
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS