Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 19-11-2007, 11:55 PM   #1 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default solve this !!


please can any one solve this in C

Quote:
*******
*** ***
** **
* *

Last edited by frogonfloor; 19-11-2007 at 11:56 PM. Reason: Automerged Doublepost
frogonfloor is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 20-11-2007, 12:05 AM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: solve this !!

Pretty simple construct really, is this a challenge or could you not do it?

Code:
#include<stdio.h>

int main()
{
    int i, j;
    for(i=4;i>0;i--)
    {
        for(j=2*i;j>0;j--)
        {
            printf("*");
            if(j==i+1)
            printf(" ");
        }
        
        printf("\n");
    }
}
Outputs as:
Code:
**** ****
*** ***
** **
* *
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 20-11-2007, 08:05 AM   #3 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: solve this !!

thank you for helping me i am new in C
but my question was this
*******
*** ***
** **
* *
not this
**** ****
*** ***
** **
* *
frogonfloor is offline  
Old 20-11-2007, 08:36 AM   #4 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: solve this !!

Huh? Doesn't look like a definite pattern to me, why would you wanna build it? Are there any rules specified?

Anyway, here's my shot again:
Code:
#include<stdio.h>

int main()
{
    int i, j, a[4]={3, 3, 2, 1};
    
    for(i=0;i<4;i++)
    {
        for(j=(2*a[i]);j>0;j--)
        {
            printf("*");
            
            if((i==0)&&(j==a[i]+1))
            {
                printf("*");
                continue;
            }
            if(j==a[i]+1)
            {
                printf(" ");
                continue;
            }
        }
        
        printf("\n");
    }
}
Outputs as:
Code:
*******
*** ***
** **
* *
Its stupid to do this when there are no rules at all cause you can directly print the pattern!
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solve It If U can....... pushkar1986 Software Q&A 33 02-03-2008 07:31 AM
Can any one solve this ???? DukeNukem QnA (read only) 4 15-06-2007 08:46 PM
Plz solve these three ?ns Siddharth Maheshwari QnA (read only) 23 24-01-2007 08:24 PM
Solve this... SystemError Software Q&A 2 11-03-2006 06:45 PM
I Bet u ll solve this.. infohardik QnA (read only) 4 26-10-2004 04:59 PM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:44 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2