#include<stdio.h>
int main(){
int num1=0;
int num2=0;
int sum=0;
printf("enter 2 numbers\n");
scanf("%d %d",&num1,&num2);
sum=num1 num2;
printf("%d",&sum);
return 0;
}
This is what i am trying but 23 23 is coming out to be 6422292 in this way.I cant find the error. Please help.
CodePudding user response:
Do NOT put an "address of" operator (&
) on this line:
printf("%d",&sum);
It should be
printf("%d", sum);
CodePudding user response:
Hey actually the error is in the printf() function
The & is your telling to print the value stored in the sum variable
Make the following changes to your code
printf("%d", sum);
Hope you got fixed the error