- Joined
- May 28, 2016
- Posts
- 790
- Solutions
- 1
- Reaction
- 132
- Points
- 286
Good Day sa inyo ma'am/sir!
Baka pwede niyo po ako matulungan about dito sa pag gawa ng simple calculator po. Bali ito po yung codes na nilagay ko.
I am using Microsoft Visual Studio 2008 since po yun daw po ang gagamitin namin sa pag gawa ng Simple Calculator using C language po.
Ito na po yung ipapatulong ko po sana, sabi po kasi sa amin nung ipinacheck namin, nag run naman po, ngayun nung mag e enter na po sa "Enter your desired number" nag enter po yung teacher namin ng puro letters, so nag error po bali ganito po yung ginawa nya, see picture po.
Ngayon po gusto ko po sana magpatulong kung anung tamang code po ba dapat ilalagay ko para kapag once na nag enter po sya ulit ng letters imbes na number, eh ang magapakita po is "This is not a valid number" po.
Sana may makatulong po. Huhuhuhu... Newbie lang po kasi ako sa C programming at yun po ang tina topic po namin ngayun semester po.
*note: refer na lang po kayu sa code na nilagay ko then paki revise na lang po kung may error man po or may maling format po. salamat po!
Baka pwede niyo po ako matulungan about dito sa pag gawa ng simple calculator po. Bali ito po yung codes na nilagay ko.
I am using Microsoft Visual Studio 2008 since po yun daw po ang gagamitin namin sa pag gawa ng Simple Calculator using C language po.
C:
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
double num1, num2, result;
char option;
do{
printf("\nWelcome to SimpCal!\n");
printf("What do you want to do?\n");
printf("Press 1 for Addition\n");
printf("Press 2 for Subtraction\n");
printf("Press 3 for Multiplication\n");
printf("Press 4 for Division\n");
scanf("%d", &n);
if(n>4)
{
printf("\n!!Please press only:\n 1 for Addition!\n 2 for Subtraction!\n 3 for Multipliation! and:\n 4 for Division!!\n");
goto loop;
}
printf("Enter your desired number: ");
scanf("%lf", &num1);
printf("Now, enter your second number: ");
scanf("%lf", &num2);
switch(n)
{
case 1:
printf("\nThe sum of %lf and %lf is %lf.\n", num1, num2, result, result=num1+num2);
break;
case 2: result=num1-num2;
printf("\nThe difference of %lf and %lf is %lf.\n",num1,num2, result);
break;
case 3: result=num1*num2;
printf("\nThe product of %lf and %lf is %lf.\n", num1,num2, result);
break;
case 4: result=num1/num2;
printf("\nThe quotient of %lf and %lf is %lf. \n", num1,num2, result);
break;
}
loop:printf("\nDo you want to try again? Y/N: \n\n");
option=getch();
}while(option=='y');
getch();
return 0;
}
Ito na po yung ipapatulong ko po sana, sabi po kasi sa amin nung ipinacheck namin, nag run naman po, ngayun nung mag e enter na po sa "Enter your desired number" nag enter po yung teacher namin ng puro letters, so nag error po bali ganito po yung ginawa nya, see picture po.
Ngayon po gusto ko po sana magpatulong kung anung tamang code po ba dapat ilalagay ko para kapag once na nag enter po sya ulit ng letters imbes na number, eh ang magapakita po is "This is not a valid number" po.
Sana may makatulong po. Huhuhuhu... Newbie lang po kasi ako sa C programming at yun po ang tina topic po namin ngayun semester po.
*note: refer na lang po kayu sa code na nilagay ko then paki revise na lang po kung may error man po or may maling format po. salamat po!
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.