A very simple program in C++ to generate a Histogram and save on the text file.
My mobile number here in the Philippines is 09173084360.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <iostream>
#include <fstream>
using namespace std;
main()
{
ofstream file("data.txt");
cout<<"\n I)- First Histogram :"<<endl;
for(int count_1=1;count_1<=10;count_1++)
{
for(int count_2=1;count_2<=count_1;count_2++)
cout<<"*";
cout << "\n";
}
cout<<"\n II)- Second Histogram :"<<endl;
for(int count_3=1;count_3<=10;count_3++)
{
for(int count_4=10;count_4>=count_3;count_4--)
cout<<"*";
cout << "\n";
}
file << "\n\n";
file <<"\n I)- First Histogram :"<<endl;
for(int count_1=1;count_1<=10;count_1++)
{
for(int count_2=1;count_2<=count_1;count_2++)
file<<"*";
file << "\n";
}
file <<"\n II)- Second Histogram :"<<endl;
for(int count_3=1;count_3<=10;count_3++)
{
for(int count_4=10;count_4>=count_3;count_4--)
file <<"*";
file << "\n";
}
file.close();
cout << "\n\n";
system("pause");
}
No comments:
Post a Comment