Error while adding two numbers in C programming? I am getting different answer?

All QuestionsCategory: C LanguageError while adding two numbers in C programming? I am getting different answer?
Chetan Shidling Staff asked 5 years ago

When I add two numbers (11 and 12) I should get an answer as 23, but I am getting larger value.

Code:

#include<stdio.h>
void add();
int main()
{
add();
return 0;
}
void add()
{
int n1,n2,sum;
printf(“enter two numbers\n”);
scanf(“%d,%d”,&n1,&n2);
sum=n1+n2;
printf(“sum=%d\n”,sum);
}

Output:

enter two numbers
11
sum=4200667
 

I am able to give only one number and getting answer a large value. Can anyone solve this problem, please?