Exforsys

Free Training

how to write a pyramid program?

This is a discussion on how to write a pyramid program? within the C and C++ forums, part of the Programming Talk category; How 2 write a pgrm 4 the output below 1 2 3 4 5 6 7 8 9 10 thanks ...

Go Back   Exforsys > Programming Talk > C and C++

Exforsys.com


C and C++ C and C++

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 06-09-2007, 02:36 AM
Junior Member
 
Join Date: Jun 2007
Posts: 5
srknth_chin2 is on a distinguished road
how to write a pyramid program?

How 2 write a pgrm 4 the output below
1
2 3
4 5 6
7 8 9 10

thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-30-2009, 08:23 AM
Junior Member
 
Join Date: Oct 2009
Location: Bangalore, India
Posts: 2
rasmiranjanbabu is on a distinguished road
Dummy Solution

Try to optimize the code

#include<stdio.h>
void main()
{
int i,j,k = 5, l=1;

for(i = 0; i <=3 ; i++)
{
for(j = 0; j <=10 ; j++)
{
if ((i == 0) && (j == 0))
{
printf("%d", l);
l++;
break;
}
if (i != j)
{
printf("%d ", l);
l++;
}
if(i == j)
{

printf("%d ", l);
l++;
break;

}


}
printf("\n");
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-31-2009, 01:04 AM
Junior Member
 
Join Date: Jul 2008
Posts: 18
moonlight is on a distinguished road
Hey, try it out

public void run() {
int base = 14;
for (int i = 0; i < base; i++)
{
for (int j = 1; j < BRICK_HEIGHT; j++)
{
int x = BRICK_WIDTH * i;
int y = getHeight() - (BRICK_HEIGHT * j);
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 07:01 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 07:00 AM
Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 rubywand@swbell.net Tech FAQ 0 04-04-2004 08:29 AM


All times are GMT -4. The time now is 01:15 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.