Saturday, October 17, 2020

c program to find the cube of a number (3 different methods)

First Method:

#include <stdio.h>

int main()

{

    int n, c;

    printf("Enter a number:");

    scanf("%d", &n);

    c = n * n * n;

    printf("Number = %d", n);

    printf("\nCube = %d", c);

    return 0;

}


Second Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    printf("Number = %d", n);

    printf("\nCube = %d", n * n * n);

    return 0;

}


Third Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    printf("Number = %d \n Cube = %d", n, n * n * n);

    return 0;

}

No comments:

Post a Comment

Back When Happiness Was Just a Bicycle Ride Away 🚲✨

The photo contains 2 bicycles and monday at bottom. So its like memory and nostalgia when getting down in the apartment to play with friends...