# C Program to calculate square and cube

Published: 2025-02-26 · By Next-G Classes · Source: https://nextgclasses.com/blog/c-program-to-calculate-square-and-cube

Question: Write a program which enters any intgers then calculate it's square and cube?<br />// Online C compiler to run C program online<br />#include &lt;stdio.h&gt;<br />void main()<br />{<br />&nbsp;&nbsp;&nbsp; int a,b,c;<br />&nbsp;&nbsp;&nbsp; printf("Enter an intger");<br />&nbsp;&nbsp;&nbsp; scanf("%d",&amp;a);<br />&nbsp;&nbsp;&nbsp; b=a*a;<br />&nbsp;&nbsp;&nbsp; printf("square is %d",b);<br />&nbsp;&nbsp;&nbsp; c=a*a*a;<br />&nbsp;&nbsp;&nbsp; printf("\n cube is %d",c);<br />} <br /><br />...........................................<br />// Online C compiler to run C program online<br />// Now Output Chnage<br />&nbsp;&nbsp;&nbsp; // square of ... is ....<br />&nbsp;&nbsp;&nbsp; //cube of ... is ....<br />#include &lt;stdio.h&gt;<br />void main()<br />{<br />&nbsp;&nbsp;&nbsp; int a,b,c;<br />&nbsp;&nbsp;&nbsp; printf("Enter an intger");<br />&nbsp;&nbsp;&nbsp; scanf("%d",&amp;a);<br />&nbsp;&nbsp;&nbsp; b=a*a;<br />&nbsp;&nbsp;&nbsp; c=a*a*a;<br />printf("square of %d is %d \n",a,b);<br />printf("cube of %d is %d",a,c);<br />}
