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



program


#include <stdio.h>

#include <conio.h>
void main()

{

    int acube;

    printf("enter a value of a to print a cube: ");

    scanf("%d", &a);

    for (int i = 1i <= ai++)

    {

        cube = i * i * i;

        printf("the cube of %d is %d \n"icube);
    }

    getch();
}

OUTPUT
Enter a value of a to print a cube: 5
The cube of 1 is 1 
the cube of 2 is 8
The cube of 3 is 27
The cube of 4 is 64
the cube of 5 is 125

Follow our page for regular updates.

0 Comments