Programming Stuff
Tips on Programming Networking and Hacking
Enter your search terms
Submit search form
Friday, January 8, 2010
CSC202 & ENG4033M : A program to input and add 2 numbers
Text Version:
/* A program to add 2 numbers */
#include "stdio.h"
int main()
{
int a,b,c;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
c = a + b;
printf("%d + %d = %d\n",a,b,c);
return 0;
}
A variation (using only one scanf):
/* A program to add 2 numbers */
#include "stdio.h"
int main()
{
int a,b,c;
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
c = a + b;
printf("%d + %d = %d\n",a,b,c);
return 0;
}
Newer Post
Older Post
Home