Posts

Showing posts from February, 2024

The Multiplication function and the Void function

  #include <iostream> using namespace std; int Mul(int a, int b) {     int ans=a*b;     return ans; } void Newfunc() {     cout<<"The problem is solved."; //used when no return type output is expected. } int main() {     int a, b;     cout<<"Give the numbers:\n";     cin>>a>>b;     cout<<"Their product is- \n";     cout<<Mul(a,b)<<endl;     Newfunc(); } --------------------------------------------------------------------------------------------------- Solution- Give the numbers: 10 8 Their product is-  80 The problem is solved.

Sum of two integers using functions

#include <iostream> using namespace std; int Sum(int p, int q) // Function declare {     int ans= p+q; //Function define     return ans; } int main() {     int a,b;     cout<<"Put any two numbers:\n";     cin>>a>>b;     cout<<"The sum is:- "<<Sum(a,b); }