In this article we will learn about C Program to Add Two Numbers Using Functions. We will define here a custom function which returns the sum of two numbers. Then we call the custom function in the main function and print the result. Please read my all articles of C-Programming here.
Check the YouTube shorts below,
C Program to Add Two Numbers Using Functions
#include<stdio.h>
//define the user defined function of Add()
int sum_digit(int x, int y){
return x+y;
}
int main(){
int a , b ,sum;
//addin inputs
printf("Enter First Number: ");
scanf("%d", &a);
printf("Enter the second Number: ");
scanf("%d", &b);
// calling the out function
sum= sum_digit(a,b);
// dispaly the output
printf("sum of two numbers is: %d", sum );
return 0;
}
To run the application you can see the output like below,

Code Explanation
- We have defined a custom function named sum_digit which returns the sum of two numbers.
int sum_digit(int x, int y){
return x+y;
}
- We have defined a custom function named sum_digit which returns the sum of two numbers.
- Then, we call the custom function in the main function. This gives us the sum of two numbers. This gets stored in the sum named variable.
// calling the out function
sum= sum_digit(a,b);
// dispaly the output
printf("sum of two numbers is: %d", sum );
Conclusion
We discussed here how to add two numbers using functions in C Programming language.
Leave behind your valuable queries and suggestions in the comment section below. Also, if you think this article helps you, do not forget to share this with your developer community. Happy Coding 🙂
Related Articles
- Building Real-Time Messaging with Kafka and .NET Core
- Effortless React Deployment 🚀: CI/CD with GitHub Actions & Azure Static Web Apps
- How to Set up an Amazon CloudFront Distribution for Amazon S3 Bucket 🚀
- Deploying Angular apps in Azure Blob Storage with CI/CD Integration 🚀
- How to Build a serverless CRUD app with Azure function and Cosmos DB
Jayant Tripathy
Coder, Blogger, YouTuberA passionate developer keep focus on learning and working on new technology.