Computing.Net > Forums > Programming > Need help with C++ Program

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help with C++ Program

Reply to Message Icon

Name: 2FAST4U (by TheWaNGeR)
Date: February 15, 2005 at 19:34:56 Pacific
OS: Windows XP Home Edition
CPU/Ram: Athlon64 3000+/ 2GB DDRSD
Comment:

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"



Sponsored Link
Ads by Google

Response Number 1
Name: tImmaY
Date: February 15, 2005 at 19:46:06 Pacific
Reply:

Doing your homework yourself will help you learn how to do it too ;)


0

Response Number 2
Name: RTAdams89
Date: February 15, 2005 at 20:58:46 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Vb help please.... Bat to find / display fil...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Need help with C++ Program

Need help with C++ program www.computing.net/answers/programming/need-help-with-c-program/5152.html

Need help with C++ program www.computing.net/answers/programming/need-help-with-c-program/19441.html

Need help with C programming www.computing.net/answers/programming/need-help-with-c-programming/6970.html