Hello!
I'm sort of a beginner as well, but can see what is your problem. You correctly initialize the num values with zero. and then:
which means that num3 holds the value of 0. However, after this, the value of num3 is not changed anywhere, and that's why it stays as 0.
Also
Code:
printf("\n\nThe answer is: %d", &num3);
should be like:
Code:
printf("\n\nThe answer is: %d", num3);
These two solutions would work:
Code:
#include<stdio.h>
main()
{
int num1=0, num2=0, num3=0;
clrscr();
printf("Enter number: ");
scanf("%d", &num1);
printf("\nEnter another number: ");
scanf("%d", &num2);
num3=num1+num2;
printf("\n\nThe answer is: %d", num3);
return 0;
}
or
Code:
#include<stdio.h>
main()
{
int num1=0, num2=0;
clrscr();
printf("Enter number: ");
scanf("%d", &num1);
printf("\nEnter another number: ");
scanf("%d", &num2);
printf("\n\nThe answer is: %d", num1+num2);
return 0;
}
Hope this helps!
Spiros