A simple program to show how to declare text files, one-dimensional arrays, creating functions using a C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg



=================================================

Want to support my the channel?



GCash Account



Jake Pomperada

09173084360



Paypal

https://paypal.me/jakerpomperada



Patreon

https://www.patreon.com/jakerpomperada



Thank you very much for your support




Program Listing

// math.cpp
// Jake R. Pomperada, MAED-IT, MIT
// www.jakerpomperada.com and www.jakerpomperada.blogspot.com
// jakerpomperada@gmail.com
// Bacolod City, Negros Occidental

#include <iostream>
#include <fstream>

using namespace std;


int add(int x, int y)
{
    return(x+y);
}

int product(int a,int b)
{
    return(a*b);
}

  int main() {
      ofstream myfile("solve.txt");
      int values[2];

      cout << "\n\n";
      cout << "\t\tProduct and Sum of Two Numbers Using Text File in C++";
      cout << "\n\n";
      cout << "Enter two numbers :=> ";
      cin >> values[0] >> values[1];
      cout << "\n";
      cout << "\nThe product of "
           << values[0] << " and "
           << values[1] << " is "
           << product(values[0],values[1])
           << ".";
        cout << "\nThe sum of "
           << values[0] << " and "
           << values[1] << " is "
           << add(values[0],values[1])
           << ".";
        
         cout << "\n\n";
         cout << "Data has been saved in solve.txt";
         cout << "\n\n";
         myfile << "\n======================";
         myfile << "\n   Resulted Values ";
         myfile << "\n======================";
         myfile << "\n";
         myfile << "\nThe product of "
           << values[0] << " and "
           << values[1] << " is "
           << product(values[0],values[1])
           << ".";
        myfile << "\nThe sum of "
           << values[0] << " and "
           << values[1] << " is "
           << add(values[0],values[1])
           << ".";
         myfile << "\n\n";
         myfile.close();
         system("pause");
  }

Leave a Reply

Your email address will not be published.