Formula Based C Programs

0 Comments

Write a c program which accept two numbers from user and find their sum.

#include<stdio.h>
#include<conio.h>

void main() 
{
int num1, num2, sum;

printf("Enter the first number: ");
scanf("%d", &num1);

printf("Enter the second number: ");
scanf("%d", &num2);

sum = num1 + num2;

printf("The sum of %d and %d is %d.\n", num1, num2, sum);

getch();
}

इस प्रोग्राम में यूजर दो इन्टिजर इनपुट लेने के लिए scanf फ़ंक्शन का उपयोग करता है और उन्हें वेरिएबल num1 और num2 में स्टोर करता है। यह तब उन्हें एक साथ जोड़कर उनकी राशि की गणना करता है और परिणाम को वेरिएबल sum में स्टोर करता है। अंत में, यह स्क्रीन पर इनपुट और परिणाम प्रदर्शित करने के लिए printf फ़ंक्शन का उपयोग करता है।

Output of the Program:

Enter the first number: 4
Enter the second number: 5
The sum of 4 and 5 is 9.