Write a program to

Prototypes for functions are

**multiply two numbers using pointers**. Make function for multiplication take input from user. There should be three function each should return a different data type int, float and double.Prototypes for functions are

This program has been tested on c++ codeblocks IDE

C++ source code:

see also: pointer addition example source code

#include <iostream> using namespace std; int Mult(int *, int *); float Mult1(int *, int *); double Mult2(int *, int *); int main(){ int a,b; cout<<"Enter 1st Value:"; cin>>a; cout<<"Enter 2nd Value:"; cin>>b; cout<<"...............Multiplication.........." <<endl <<endl; cout<<"The integer Multiplication of these numbers is:"<<Mult(&a,&b)<<endl; cout<<"zThe float Multiplication of these numbers is:"<<Mult1(&a,&b)<<endl; cout<<"The double Multiplication of these numbers is:"<<Mult2(&a,&b)<<endl; cout<<endl <<endl; return 0; } int Mult(int *x, int *y){ int Prod; Prod=(*x * *y); return Prod; } float Mult1(int *x, int *y){ float Prod; Prod=(*x * *y); return Prod; } double Mult2(int *x, int *y){ double Prod; Prod=(*x * *y); return Prod; }

Program input output

If you do not want to write prototypes just add three methods above main method.

**Suggestion number 1**

I suggest first remove the prototypes than examine the errors compiler (IDE) will show this will help to understand errors also.

**Suggestion number 2**

We have 3 methods with all methods take two integers as arguments. Try by changing argument data types and return types and and examine the different cases in which your code is working and not working.

Do experiment with code for fast learning. Each and every time you face an error you learn. Good luck

Find more: c++ programming simple examples

## 0 comments:

## Post a Comment