Hello Everybody.I need to write a C++ program(block letters via functions)
Firstly, write a function
void line( char ch, int num)
which outputs the character ch num times in a row on a given line.
Secondly, write a function
void rectangle (char ch, int x, int y)
which writes the character ch in a rectangular pattern of x rows and y columns.
Thirdly, write a main body to read one character at a time from animals.dat.Th eprogram should produce a rectangular pattern for each letter in the animals name; the size of the rectangular pattern depends on the letter and on its position in the animal name, the rule being: if the x th letter in the name is the y th letter of the alphabet, the rectangle should be size x by y.
This is what i got so far . Thank you for the help
You are closing the 'rectangle' function brace too early ( Line 28 ). You are not using the x parameter ( nor naming it )
You would need two nested loops there.
#include <iostream>
#include <fstream>
void line(char ch, int num);
void rectangle(char ch, int x, int num);
usingnamespace std;
void line(char ch, int num)
{
for(int i=1; i<=x;i++)
{
cout<<ch;
fout<<ch;
}
}
void rectangle (char ch , int x, int y)
{
line(ch,num);
for(int j=1; j=y; j++)
{
cout<<endl<<endl;
fout<<endl<<endl;
}
}
int main()
{
ifstream fin;
ofstream fout;
fin.open("animals.dat");
int i,j;
for(int j=1; j=y; j++)
{
cout<<endl<<endl;
cout<<endl<<endl;
}
return 0;
}
and it's still will be have an errors. You should read some tutorials about c++. This web site is perfect for that.
I hope that you don't looking for a guy (loser) whose gonna write that program for you
jjlimax, most of the errors you've had so far have been obvious and indicated by the compiler. At least post the errors so we may help and finish this thread.