#include<stdio.h>
int math(int);
void main()
{
int choice,no;
while(1)
{
clrscr();
printf("\n1. Square of number\n2. Area of square\n"
"3. Reverse number\n4. Exit\n");
printf("\nEnter choice : ");
scanf("%d",&choice);
if(choice<1||choice>3)
break;
if(choice==1)
printf("\nEnter no. to square : ");
if(choice==2)
printf("\nEnter side of square : ");
if(choice==3)
printf("\nEnter no. to reverse : ");
printf("Answer = %d",math(choice));
getch();
}
}
int math(int ch)
{
int no,rem,temp=0,revno=0;
scanf("%d",&no);
if(ch==1||ch==2)
return no*no;
else
{
while(no>0)
{
rem=no%10;
revno=temp+rem;
temp=revno*10;
no=no/10;
}
return revno;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.