Program in C and C++ to calculate sum of three numbers using function
C
CPP
#include<stdio.h> int Add(int a,int b,int c) { return (a+b+c); } int main() { int x,y,z,r; printf("Enter three numbers:-"); scanf("%d%d%d",&x,&y,&z); r=Add(x,y,z); printf("Sum = %d",r); return 0; }
#include<iostream> using namespace std; int Add(int a,int b,int c) { return (a+b+c); } int main() { int x,y,z,r; cout<<"Enter three numbers:-"; cin>>x>>y>>z; r=Add(x,y,z); cout<<"Sum = "<<r; return 0; }
Output:-
0 Comments