0

This is what i have done so far
but i want the output like that
square#1:not an increasing square
square#2: increasing square
square#3: not an increasing square

please help

Help with Code Tags
C++ Syntax (Toggle Plain Text)

#include <iostream>
#include <fstream> // Header to use input and output
#include <string> 
 
using namespace std;
 
void main()
 
{
      ifstream ifile; // declare file stream variables
      ofstream ofile;
 
    int m[20][20];
	int i , j , n;
 
 
	char fileName[100];
	cout <<" please enter the name of the data file "<< endl; // prmot the user to enter the name of the datafile
 
    cin>>fileName;   // user inputs the file
    ifile.open(fileName); // ifile stream looks for the file 
 
	ifile>>n;
	cout<<"The data for "<< n << " squares to check. " <<endl; 
	cout << "\n";
for (i=0; i<12; i++) 
      { 
for(j=0;j<4;j++){
		ifile>>m[i][j]; 
	  }
}
 
for (i=0;i<12;i++)
	{
		cout << "\n| ";
		for (j=0;j<4;j++)
		{
			cout << " | ";
			cout << m[i][j];
		}
	}
 
 
ifile.close();// c;ose file stream variables
ofile.close();

}
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by VernonDozier
0

Here is your code, formatted. It's much easier to read. Perhaps you are mixing spaces and tabs? Don't. It will look terrible on Daniweb if you do.

#include <iostream>
#include <fstream> // Header to use input and output
#include <string> 

using namespace std;

void main()

{
	ifstream ifile; // declare file stream variables
	ofstream ofile;

	int m[20][20];
	int i , j , n;


	char fileName[100];
	cout <<" please enter the name of the data file "<< endl; // prmot the user to enter the name of the datafile

	cin>>fileName;   // user inputs the file
	ifile.open(fileName); // ifile stream looks for the file 

	ifile>>n;
	cout<<"The data for "<< n << " squares to check. " <<endl; 
	cout << "\n";
	for (i=0; i<12; i++) 
	{ 
		for(j=0;j<4;j++)
                {
			ifile>>m[i][j]; 
		}
	}

	for (i=0;i<12;i++)
	{
		cout << "\n| ";
		for (j=0;j<4;j++)
		{
			cout << " | ";
			cout << m[i][j];
		}
	}


	ifile.close();// c;ose file stream variables
	ofile.close();

}

You're going to have to elaborate on what the problem is. You have provided no output, nor have you provided an input file, so this is vague:

square#1:not an increasing square
square#2: increasing square
square#3: not an increasing square

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.