Sunday, October 18, 2020

c program to find cube and square of a number (3 distinct methods)

First Method:

#include <stdio.h>

int main() {

    int n, s, c;

    printf("Enter Number:");

    scanf("%d", &n);

    s = n * n;

    c = n * n * n;

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

    printf("\nSquare = %d, Cube = %d", s, c);

    return 0;

}


Second Method:

#include <stdio.h>

int main() {

    int n;

    printf("Enter Number:");

    scanf("%d", &n);

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

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

    return 0;

}


Third Method:

#include <stdio.h>

int main() {

    int n;

    printf("Enter Number:");

    scanf("%d", &n);

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

    return 0;

}

No comments:

Post a Comment

The Power of a Genuine Compliment: A Small Kindness That Can Change Your Day 😊

  https://www.youtube.com/watch?v=i1gDGLY4kC8 Hi, namaste. Kamcho. So, uh I was just thinking like I was working now. It's almost going ...