Q:

Incorrect answer in C program, what I am missing?

The following C program is for finding the value of formula (a+b)^2. 
#include <stdio.h>
#include <conio.h>
void main()
{
int a ,b , c;
clrscr ();
printf ("\n ENTER THE VALUE OF A AND B:");
scanf("%d %d", &a,&b);
c = a*a + b*b +2*a*b;
printf(" \n THE FINAL RESULT IS = %d ", c);
getche();
}

Upon running, when I enter the value for a and b as 1 and 88888, then it gives -688680271 as answer:
" ENTER THE VALUE OF A AND B:1 88888
 THE FINAL RESULT IS = -688680271 "
But the answer is wrong, it should be 7901254321. Please help. Thx

A:

Do you know that an int is normally only 32 bits wide?
88888 * 88888 = 7901076544

Which already requires 33 bits to represent. You have an integer overflow. Try using long long int as your type.
long long int a ,b , c;
// ...
scanf("%lld %lld", &a,&b);
// ...
printf(" \n THE FINAL RESULT IS = %lld ", c);

