adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C and C++ to calculate sum of three numbers using function

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:-







Post a Comment

0 Comments