Template Information

Tuesday, 3 July 2012

C program to add two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
        int num_1,num_2,ans;
        printf("Enter the value of num_1 = ");
        scanf("%d",&num_1);
        printf("\nEnter the value of num_2 = ");
        scanf("%d",&num_2);
        ans= num_1 + num_2;
        printf("\nthe sum of two number is = %d",ans);
        getch();
}
Sample Output:
Enter the value of num_1 =8

Enter the value of num_2 =9

the sum of two number is = 17




0 comments: