The code below demostrates how one can came up with simple calculator
using borland C.This code code targets young programmer to get used to
programing . the Code is very clear with an understanding and claear
procedures. Thanks Best reguards in coding.
=======================================================================
#include <stdio.h>
int main()
{
int num;
int num2;
char choice;
int i;
for (;;){
do {
printf("WELCOME TO LUCKYCODERS CALCULATOR");
printf("\n");
printf("Please choose an option by entering the number\n");
printf("1 - Addition\n");
printf("2 - Subtraction\n");
printf("3 - Division\n");
printf("4 - Multiplication\n");
printf("5 - Help\n");
printf("6 - About This Program\n");
printf("7 - Updates to this program\n");
scanf("%s",&choice);
}
while ( choice < '1' , choice > '7' && choice != 'q');
if (choice == 'q')
break;
switch (choice)
{
case '1':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another number to be added\n");
scanf("%d",&num2);
num + num2;
printf("The answer after addition is %d\n",(num + num2));
printf("\n");
break;
case '2':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another number to be subtracted\n");
scanf("%d",&num2);
num - num2;
printf("The answer after subtraction is %d\n",(num - num2));
printf("\n");
break;
case '3':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another one to be divided\n");
scanf("%d",&num2);
num / num2;
printf("The answer after divisition is %d\n",(num / num2));
printf("The Remainder after division is %d\n",(num%num2));
printf("\n");
break;
case '4':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another one to be multiplied\n");
scanf("%d",&num2);
num * num2;
printf("The answer after multiplication is %d\n",(num * num2));
printf("\n");
break;
case '5':
printf("This is a simple calculator made by Luckycoders programmer.\n");
printf("To select an option, type the number next to the option and press enter\n");
printf("E.G. for multiplication, you would type 4 and press enter.\n");
printf("\n");
break;
case '6':
printf("the luckycoderscalculator, made by luckycoders programmer - Copyright 2016. :)\n");
printf("Feedback would be nice - mugishachristopher94@gmail.com or call +256 783939501 also, what programmes\n");
printf("do people need. Please give us ideas for programs. best reguards!!\n");
printf("\n");
break;
case '7':
printf("Updates include: -int variable instead of double, since it is the intital can be used.\n");
printf(" -do while loop so that you can exit the program yourself\n");
printf("\n");
break;
default:
printf("That is not an option");
}
}
return 0;
}
=======================================================================
#include <stdio.h>
int main()
{
int num;
int num2;
char choice;
int i;
for (;;){
do {
printf("WELCOME TO LUCKYCODERS CALCULATOR");
printf("\n");
printf("Please choose an option by entering the number\n");
printf("1 - Addition\n");
printf("2 - Subtraction\n");
printf("3 - Division\n");
printf("4 - Multiplication\n");
printf("5 - Help\n");
printf("6 - About This Program\n");
printf("7 - Updates to this program\n");
scanf("%s",&choice);
}
while ( choice < '1' , choice > '7' && choice != 'q');
if (choice == 'q')
break;
switch (choice)
{
case '1':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another number to be added\n");
scanf("%d",&num2);
num + num2;
printf("The answer after addition is %d\n",(num + num2));
printf("\n");
break;
case '2':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another number to be subtracted\n");
scanf("%d",&num2);
num - num2;
printf("The answer after subtraction is %d\n",(num - num2));
printf("\n");
break;
case '3':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another one to be divided\n");
scanf("%d",&num2);
num / num2;
printf("The answer after divisition is %d\n",(num / num2));
printf("The Remainder after division is %d\n",(num%num2));
printf("\n");
break;
case '4':
printf("Please enter a number\n");
scanf("%d",&num);
printf("Another one to be multiplied\n");
scanf("%d",&num2);
num * num2;
printf("The answer after multiplication is %d\n",(num * num2));
printf("\n");
break;
case '5':
printf("This is a simple calculator made by Luckycoders programmer.\n");
printf("To select an option, type the number next to the option and press enter\n");
printf("E.G. for multiplication, you would type 4 and press enter.\n");
printf("\n");
break;
case '6':
printf("the luckycoderscalculator, made by luckycoders programmer - Copyright 2016. :)\n");
printf("Feedback would be nice - mugishachristopher94@gmail.com or call +256 783939501 also, what programmes\n");
printf("do people need. Please give us ideas for programs. best reguards!!\n");
printf("\n");
break;
case '7':
printf("Updates include: -int variable instead of double, since it is the intital can be used.\n");
printf(" -do while loop so that you can exit the program yourself\n");
printf("\n");
break;
default:
printf("That is not an option");
}
}
return 0;
}
0 comments:
Post a Comment