DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    1

    need some help in a program

    hi, i need some help in a program which has to be in C++ languge: the program is to draw a pyramid of stats (*), only the front of it that the user will input the number of lines of the stars. how do i wright the sentix of such a program!!!

  2. #2
    Join Date
    Feb 2006
    Posts
    133
    This is an optional solution:

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {	
    	int row;
    	int startrow;
    	int num;
    	int counter;
    	
    	cout << "Give the number of rows of the pyramid:" << endl;
        cin >> row;
        
    	counter = 1;
        for(startrow = row; row>0;--row)
    	{   
    		//Drawing blancs
    		for(num=startrow-counter;num>0;num--)
    		{
    			cout << " " ;
    		}
    		
    		//Drawing stars
    		for(num=(counter*2)-1; num > 0;num--)
    		{
    			cout << "*";
    		}
    
    
    		cout << endl;		
    		counter++;
    	}
    
    
    	return 0;
    }
    Hope this helps.

    Benjamin

Similar Threads

  1. Help with a program
    By stormswimmer in forum Java
    Replies: 2
    Last Post: 01-02-2006, 03:17 PM
  2. problem in program in c++
    By mheasen in forum Architecture and Design
    Replies: 0
    Last Post: 03-20-2002, 09:24 AM
  3. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 10:06 AM
  4. How can I build copy protection into my program
    By W.Pierce in forum VB Classic
    Replies: 1
    Last Post: 12-11-2001, 08:28 AM
  5. Replies: 0
    Last Post: 12-15-2000, 10:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links