Solved programming problem

Find the Square and Cube with function in C.

Source code

#include<stdio.h>

void print(int m) ///Receive the integer

{

   int square,cube;

   square=m*m;

   cube=m*m*m;

   printf("%d Square Is: %d",m,square);

   printf("%d Cube Is: %d",m,cube);

}

int main()

{

    int n;

    printf("Please Enter A Number: ");

    scanf("%d",&n);

    print(n); ///call the function and pass the integer

    return 0;

}

Output

Please Enter A Number: 2

2 Square Is: 4


2 Cube Is: 8

Join the discussion

Add your comment