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, suggestions in the comment section below. Also, if you think this article help to you, do not forget to share this within your developer community. Happy Coding 🙂
Related Articles
- ChatGPT Integration in ASP.Net Core using OpenAI
- How many ways we can call an API in JavaScript
- How to Implement AutoMapper in ASP.Net Core – Beginner’s Guide
- Building CI/CD Pipeline using Azure DevOps- Part 2
- C# Constructor- Complete Guide
Jayant Tripathy
Coder, Blogger, YouTuberA passionate developer keep focus on learning and working on new technology.