Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey, i need help on how to create a program that has a user inputs an integer and a character. The output should be a diamond composed of the character given, and extending the width specified by the integer. Example, if a user inserts 11 as the integer, and an * (asterick) as the character, then the output would be...
*
***
*****
*******
*********
***********
*********
*******
*****
***
*Like that. If you could write up a program for me, then I will understand how the program works, and will finally be able to explain how to do this problem to myself and others. Thank you!
"Don't let the Hammer hammer you in wolfenstein"

Try this for starters:
#include <iostream>
#include <string>
using namespace std;
int main()
{
char character;
cout << "Input character: ";
cin >> character;float number;
cout << "Input number: ";
cin >> number;float k = 1;
while (k <= number)
{
float rep = (number - k);while ( rep < number )
{
cout << character;
rep++;
}
cout << "\n";
k++;
k++;
}
k = 1;
while (k <= number)
{float rep = k;
while ( rep < number )
{
cout << character;
rep++;
}
cout << "\n";
k++;
k++;
}
system("PAUSE");
return 0;
}-Ryan Adams
Ryan's
Custom Cables

![]() |
Vb help please....
|
Bat to find / display fil...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |