Program To Display Either Square Or Square Root Or Cube Of The Given Integer
/* PROGRAM TO DISPLAY EITHER SQUARE OR SQUARE ROOT OR CUBE OF THE GIVEN INTEGER VALUE BASED ON THE USERS CHOICE */ #include
#include
#include
void main() { int n; long r; float res; char ch; clrscr(); printf("\nEnter an integer value\n\n"); scanf("%d",&n); fflush(stdin); printf("\nenter (s)quare, (c)ube or s(q)uare root\n\n"); ch=getchar(); if(ch=='s') { r=n*n; printf("\nsquare of %d = %d",n,r); } else if(ch=='c') { r=n*n*n; printf("\ncube of %d = %d",n,r); } else if(ch=='q') { res=sqrt(n); printf("\nsquareroot of %d = %f",n,res); } else printf("\ninvalid option"); getch(); }
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/