-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathAddTwoNumbersFn.c
54 lines (51 loc) · 1.67 KB
/
AddTwoNumbersFn.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/******************************************************
* File : AddTwoNumbersFn.c
* Description : Create a function in C programe to add two integer numbers
* Author : Sarju S
* Version : 1.0
* Date : 05/09/2021
* ***************************************************/
#include<stdio.h>
//function prototype
void sum();
void sumArgs(int,int);
int sumArgsRet(int,int);
int main(){
int number1,number2;
int sumOfNumbers;
sum();
printf("\nReading from Main:\n");
printf("\nEnter the two integer numbers:");
scanf("%d%d",&number1,&number2);
//Actual Parameters number1 & number2
sumArgs(number1,number2);// calling fn
printf("\nReading from Main:\n");
printf("\nEnter the two integer numbers:");
scanf("%d%d",&number1,&number2);
//Actual Parameters number1 & number2
// printf("%d",sumArgsRet(number1,number2));
sumOfNumbers = sumArgsRet(number1,number2);
printf("\nPrinting at Main:\n");
printf("\n%d + %d = %d",number1,number2,sumOfNumbers);
return 0;
}
void sum(){//fn definition
int number1,number2,sumOfNumbers;
printf("\nReading from the Function:\n");
printf("\nEnter the two integer numbers:");
scanf("%d%d",&number1,&number2);
sumOfNumbers = number1 + number2;
printf("\n%d + %d = %d",number1,number2,sumOfNumbers);
}
//Formal Parameters number3, number4
void sumArgs(int number3, int number4){
int sumOfNumbers;
sumOfNumbers = number3 + number4;
printf("\n%d + %d = %d",number3,number4,sumOfNumbers);
}
int sumArgsRet(int number5, int number6){
int sumOfNumbers;
sumOfNumbers = number5 + number6;
return sumOfNumbers;
//return number5 + number6;
}