need some help in a program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: need some help in a program

  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, 04:17 PM
  2. problem in program in c++
    By mheasen in forum Architecture and Design
    Replies: 0
    Last Post: 03-20-2002, 10:24 AM
  3. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 11: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, 09:28 AM
  5. Replies: 0
    Last Post: 12-15-2000, 11:07 PM

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center