A simple program to ask the user to give two numbers that will compute the product of two numbers using pointers in C++ programming language.
My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com
Program Listing
// product.cpp
// Jake Rodriguez Pomperada, MAED-IT, MIT
// www.jakerpomperada.blogspot.com www.jakerpomperada.com
// jakerpomperada@gmail.com
#include <iostream>
int main()
{
int val1=0,val2=0;
int *ptr1,*ptr2;
int solve_product = 0;
std::cout << "\n\n";
std::cout << "\tProduct of Two Numbers in Pointers Using C++";
std::cout << "\n\n";
std::cout << "\tGive First Value : ";
std:: cin>>val1;
std::cout << "\n\n";
std::cout << "\tGive Second Value : ";
std:: cin>>val2;
ptr1=&val1;
ptr2=&val2;
// Solving the product here
solve_product=*ptr1 * *ptr2;
std::cout << "\n\n";
std::cout << "\tThe product of " << val1 << " and " << val2
<< " is " << solve_product << ".";
std::cout << "\n\n";
std::cout << "\tEnd of Program";
std::cout << "\n\n";
system("pause");
}
No comments:
Post a Comment