Monday, 8 April 2013

mini call all


#include<stdio.h>

void menu(void);
void smallMenu(void);
float getInteger(void);
float value(float num);
float add(float x, float y);
float sub(float x, float y);
float multiple(float x, float y);
float divide(float x, float y);
float reminder(float x, float y);
void displayAdd(float x, float y, float result);
void displaySub(float x, float y, float result);
void displayMultiple(float x, float y, float result);
void displayDivide(float x, float y, float result);
void displayReminder(float x, float y, float result);

void main()
{
menu();
}
void menu(void)
{
int choice;

printf("1. Addition\n");
printf("2. Substraction\n");
printf("3. Multiple\n");
printf("4. Divide\n");
printf("5. Reminder\n");
printf("0. Exit\n");

printf("Please enter your choice:");
scanf("%d", &choice);

if(choice==1)
{
float a,b;
float result;

a=getInteger();
b=getInteger();
result=add(a,b);
displayAdd(a,b,result);

}
else if(choice==2)
{
float a,b;
float result;

a=getInteger();
b=getInteger();
result=sub(a,b);
displaySub(a,b,result);

}
else if(choice==3)
{
float a,b;
float result;

a=getInteger();
b=getInteger();
result=multiple(a,b);
displayMultiple(a,b,result);

}
else if(choice==4)
{
float a,b;
float result;

a=getInteger();
b=getInteger();
result=divide(a,b);
displayDivide(a,b,result);

else if(choice==5)
{
float a,b;
float result;

a=getInteger();
b=getInteger();
result=reminder(a,b);
displayReminder(a,b,result);
}
else if(choice==0)
{
printf("Thank You and Bye...\n");
}
else
{
menu();
}

}
void smallMenu(void)
{
int choice;

printf("1. Menu\n");
printf("0. Exit\n");

printf("Please enter your choice:");
scanf("%d", &choice);

if(choice==1)
{

menu();
}
else if(choice==0)
{
printf("Thank You and Bye...\n");
}
else
{

smallMenu();
}
}
float getInteger(void)
{
float num;

printf("Please enter your value:");
scanf("%f", &num);

return num;

}
float add(float x, float y)
{
return x+y;
}
float sub(float x, float y)
{
return x-y;
}
float multiple(float x, float y)
{
return x*y;
}
float divide(float x, float y)
{
return x/y;
}
float reminder(float x, float y)
{
return x/y;
}
void displayAdd(float x, float y, float result)
{
printf("%.2f + %.2f = %.2f\n",x,y,result);
}
void displaySub(float x, float y, float result)
{
printf("%.2f - %.2f = %.2f\n",x,y,result);
}
void displayMultiple(float x, float y, float result)
{
printf("%.2f * %.2f = %.2f\n",x,y,result);
}
void displayDivide(float x, float y, float result)
{
printf("%.2f / %.2f = %.0f\n",x,y,result);
}
void displayReminder(float x, float y, float result)
{
printf("%.2f / %.2f = %.2f\n",x,y,result);
}

No comments:

Post a Comment