bacn wala nako natarong ug copy kang smarkies. i-try lng na kang smarkies peru ibaylo lng ang order sa input
bacn wala nako natarong ug copy kang smarkies. i-try lng na kang smarkies peru ibaylo lng ang order sa input
Copied the original code by smarkies and edited..
The same result ra giahpon bro. T_T I think I'll have to go with the magic line nga
Anyways, naka decide diay ko nga ang corrected program ni smarkies (original one) ang akong gamiton kay simple ra (Bahala na nagbaylo ang order sa paginput..Code:void main(void); { . .. ... printf("Choices: ... "); c=getche(); }). If I will use man gud the other programs introduced to me, musaka nya ang kilay sa among maestra ngano advanced kaayo akong program. xD
Nonetheless, I would like to express my eternal gratitude to all programmers who patiently helped me in my endeavor. MABUHAY KAYONG LAHAT!![]()
Last edited by marcdaven; 02-11-2010 at 11:11 PM. Reason: Final adopted program
I managed to compile a c program under visual studio 2008. pwede ra mn diay isulod sa c++ file/project.
i think mao na ni. i found out nga case sensitive ang compiler so instead of if(c=='A'), use if(c=='a')... I'm not sure though but mao akong na-obserbahan sa akong compiler. hehe
PHP Code:
#include<stdio.h>
#include<conio.h>
int add(int, int);
int subtract(int, int);
float divide(int, int);
int multiply(int, int);
int main()
{
int a, b, d, e, f;
float g;
char c;
printf("\nEnter two integers separated by a space: ");
scanf("%d %d", &a, &b);
printf("Select an operation:\n(a) Add\n(s) Subtract\n(d) Divide\n(m) Multiply\n");
printf("Choice: ");
scanf("%c",&c);
c = getche();
if (c=='a')
{
d=add(a, b);
printf("\nThe sum of %d and %d is %d\n", a, b, d);
}
if (c=='s')
{
e=subtract(a, b);
printf("\nThe difference of %d and %d is %d\n", a, b, e);
}
if (c=='d')
{
g=divide(a, b);
printf("\nThe quotient of %d and %d is %.2f\n", a, b, g);
}
if (c=='m')
{
f=multiply(a, b);
printf("\nThe product of %d and %d is %d\n", a, b, f);
}
getch();
return 0;
}
int add(int a, int b)
{
return (a+b);
}
int subtract(int a, int b)
{
return (a-b);
}
int multiply(int a, int b)
{
return (a*b);
}
float divide(int a, int b)
{
return ((float)a/b);
}
if you want to be sure kung case sensitive ba ang input.
use
PHP Code:
if (c=='a' || c=='A')
{
d=add(a, b);
printf("\nThe sum of %d and %d is %d\n", a, b, d);
}
aw pwede ra mn void main(void).
int main() mn gud to ako sauna.
kung mag void ka, ayaw na pag return 0;
pwede ra mn cguro getche(); hehe
pwede ra mn cguro na ilisan nimo ug getch() instead of getche()... specifically c = getch();
ok ra mn sa akong compiler. awat2x ra mn ko anang getche() sa mga uban ga post diri. hehe.
Haha! Di ko ganahan mugamit ug program nga wla ko naka sabot sa each part sa program. xD
revised...
getch() na akong gamit, dili na getche... tapos case insensitive na.
PHP Code:
#include<stdio.h>
#include<conio.h>
int add(int, int);
int subtract(int, int);
float divide(int, int);
int multiply(int, int);
int main()
{
int a, b, d, e, f;
float g;
char c;
printf("Enter two integers separated by a space: ");
scanf("%d %d", &a, &b);
printf("Select an operation:\n(a) Add\n(s) Subtract\n(d) Divide\n(m) Multiply\n");
printf("Choice: ");
scanf("%c",&c);
c = getch();
if (c=='a' || c=='A')
{
d=add(a, b);
printf("\nThe sum of %d and %d is %d\n", a, b, d);
}
if (c=='s' || c=='S')
{
e=subtract(a, b);
printf("\nThe difference of %d and %d is %d\n", a, b, e);
}
if (c=='d' || c=='D')
{
g=divide(a, b);
printf("\nThe quotient of %d and %d is %.2f\n", a, b, g);
}
if (c=='m' || c=='M')
{
f=multiply(a, b);
printf("\nThe product of %d and %d is %d\n", a, b, f);
}
getch();
return 0;
}
int add(int a, int b)
{
return (a+b);
}
int subtract(int a, int b)
{
return (a-b);
}
int multiply(int a, int b)
{
return (a*b);
}
float divide(int a, int b)
{
return ((float)a/b);
}
Similar Threads |
|