Write a Program to perform the action as per the user's choice

//This is a Program to perform the action as per the user's choice
#include<stdio.h>
#include<conio.h>
void main()
{
int choice,ans,num;

printf("\n\nMenu");
printf("\n\n1.Square");
printf("\n\n2.Cube");
printf("\n\n3.Octal Format");
printf("\n\n4.Hexa-Decimal Format");

printf("\n\nEnter Your Choice(1/2/3/4): ");
scanf("%d",&choice);

printf("\n\nEnter the number: ");
scanf("%d",&num);

if(choice==1)
{
ans=num*num;
printf("\n\n Square=%d",ans);
}
else if(choice==2)
{
ans=num*num*num;
printf("\n\n Cube=%d",ans);
}
else if(choice==3)
{
printf("\n\n Octal Format=%o",num);
}
else if(choice==4)
{
printf("\n\n Hexa-Decimal Form=%x",num);

}
else
{
printf("\n\nWronge Choice");
}
getch();
}

Previous
Next Post »