C++ program Sum the Three Integers Using function
Function:
Functions are self contained modules of code that accomplished a specific task. function usually take data , process it and return a result.
code:
#include<iostream>
using namespace std;
int main()
{
void sum(int, int, int);
int number1, number2, number3;
cout << "This Program Calcuates sum of three number:" << "\n";
cout << "Enter 1st number:";
cin >> number1;
cout << "Enter 2nd number:";
cin >> number2;
cout << "Enter 3rd number:";
cin >> number3;
sum(number1, number2, number3);
system("pause");
}
void sum(int number1, int number2, int number3)
{
int sum = 0;
sum = number1 + number2 + number3;
cout << "Sum of three number is:" << sum;
}
*------------------------------------------------------------------------------------------------------*
#include hum is liya likhta hain taka hum ak header file ko samil kar saka. jasa ke "iostream" is program ma samil kia. header files ko is liya hum istimal karta hai q ka us ma pahla sa he kuch functions ko store karwa lia jata hai. Taka baad ma humay bar bar usay likhna na paray bs us ke header file ko shamil kar ka us function ko call kar lia jae .
0 comments:
Post a Comment