hi gues am new to embedded c,i wrote programm to addition of two numbers

but i didn't get the result....

I don't what is the wrong in my code

my code is:

include <reg51.h>
#include <stdio.h> extern unsigned int getnumber (void);
extern void output (unsigned int);

void main (void)
{
unsigned int number1, number2;
bit operation;

SCON = 0x50;
TMOD = 0x20;
TR1 = 1;
T1 = 1;
TH1 = 221;
printf ("hi yuvaraj");

while (1) {
number1 = getnumber ();
number2 = getnumber ();
printf ("Input operation: '+' (ADD) or '-' (SUB) ? ");
operation = (getchar () == '+');
output (operation ? (number1 + number2) /* perform operation */ : (number1 - number2) );
}
}


please help me

//...
flush(stdin);
operation = (bit)(getchar() == (int)'+');
//...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.