I am new to C and i can't understand where its getting these numbers from
/* my test program */
#include <stdio.h>
main()
{
int num1, num2 , total;
printf("Hello and welcome to data link Plc \n");
printf("*********************************** \n");
printf("** Data Link ** \n");
printf("** ** \n");
printf("*********************************** \n");
printf(" \n");
printf(" \n");
printf(" Which number do you wish to add up please enter \n");
printf("the first number : " );
num1 = getc( stdin );
printf(" Which Second number do you wish to enter ? \n");
num2 = getc( stdin );
total = num1 + num2;
printf("\n");
printf("********************************************* \n");
printf("** ** \n");
printf("** %d + %d = %d ** \n", num1, num2, total);
printf("********************************************* \n");
return 0;
}
as you can see i have declare my variable ok so i want the results to look like this
23 + 2 = 25
but the user inputs any number and the program justs adds them up .
could someone explains to me why is it that its keep on giving me 50 and 60 instead.




Reply With Quote