Skip to main content
Write a program to calculate the square and cube of an entered number using pointer of a variable containing the entered number.
CODING:
#include <stdio.h>
#include<conio.h>
void main()
{
 int no;
 int *ptr=&no;
 clrscr();

 printf("\nEnter a no. : ");
 scanf("%d",&no);
 printf("\nSquare\t= %d",(*ptr)*(*ptr));
 printf("\nCube\t= %d",(*ptr)*(*ptr)*(*ptr));

 getch();
}

Comments