Thread: someone pliz help!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    31

    Question someone pliz help!

    can someone pllllllllllllllllz help me with this!!!!!!!!

    my problem is

    i have to write a c++ program that inputa a character and an integer. The out put should be a diamond composed of the character and extencing the widht specified byt he integer. for example, if the integer is 11 and the character is an asterisk (*), the diamond would look like this:
    Code:
              *
            ***
           *****
          *******
         *********
       ***********
         *********
           *******
             *****
               ***
                 *
    if the input integer is an even number, it should be increased to the next odd number.
    i have tried this out..but i think my logic is wrong...pliz help me on this
    Code:
    # include <iostream>
    
    using namespace std;
    
    
    
    int main()
    { 
    	int n, r, oddInt;
    	char c;
    
    	
    	// Get int and char
    
    	cout << "Enter number of rows: "<< flush;
    	cin  >> n;
    	cout << "Enter a character: "<< flush;
    	cin  >> c;
    	
    	// determine whether n is odd or even
    	
    	if (n > 1 && n < 23)
    	{
    
    		oddInt = 3;
    		while ( oddInt <= 23)
    		{
    			oddInt = oddInt + 1;
    		
    		}
    	
    		
    	}
    	else if ( n < 1 && n > 23)
    	{
    		cout << "Illegal integer"<< endl;
    	}
    	
    	// draw triangle
    		// r = row
    		// s = space
    		
    	r= 1;
    	while ( r <= n)
    	{		
    		c = 1;
    		
    		while (c <= r )
    		{ 
    			cout << c;
    			c++;
    		}
    
    		r++;
    		cout << endl;
    	
    
    	}	
    
    	return 0;
    }
    [b]Code Tags added by Kermi3[/code]
    Last edited by Nikisha; 03-16-2003 at 10:44 PM.

Popular pages Recent additions subscribe to a feed