write a program in c Input any two numbers and display sum of these numbers.
Answers
#include <stdio.h>
int num1,num2,num3; /* declaration of three variables */
int sum;
char line_text[50]; /* line of input from keyboard */
int main()
{
printf("Input three numbers separated by comma : ");
fgets(line_text, sizeof(line_text), stdin);
sscanf(line_text, "%d, %d, %d", &num1, &num2, &num3);
sum = num1+num2+num3;
printf("The sum of three numbers : %d\n", sum);
return(0);
}
This is modern C language, and the language in figure is also C language but it is old.
#include<studio.h>
#include<conio.h>
int main()
clrscr();
{
int a;
int b;
printf("enter the first number:");
scanf("%d",&a);
printf("enter the second number:");
scanf("%d",&b);
int c = a + b
printf ("Result: %d",c);
getch();
}
OUTPUT
Enter the first number: 2
Enter the second number: 3
Result: 5