# I need to achieve this task urgently

Page 1 of 1

## 4 Replies - 693 Views - Last Post: 30 March 2013 - 06:34 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=317182&amp;s=818aa546dd5240f80cb4dc1bad35d873&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 princeola

Reputation: 0
• Posts: 2
• Joined: 30-March 13

# I need to achieve this task urgently

Posted 30 March 2013 - 12:43 AM

Hi,
please I have been trying to write a code in C to prompt for # input, to create a height of 8 steps of pyramid in horizontal shapes. This is what I have tried on doing:
```# include <stdio.h>
# include <math.h>

int main (int argc, char* argv[])
{
int iterations = GetInt();

if (iterations == 8)
{
printf("iterations is 8 :)/>\n");
}
else
{
printf("iterations is not 8 :)/>\n);

for(int i = 0; i > iterations; i++)
{
printf("%d\n");
}

int i = 8;

iterations=9;

while (i => iterations)

{
printf("%d\n");

i++;

i = i + 1;

i += 1;

}
}
```

I want to achieve something like this:
#
##
###
####
#####
######
#######
########

This post has been edited by Salem_c: 30 March 2013 - 01:45 AM
Reason for edit:: fixed the tags

Is This A Good Question/Topic? 0

## Replies To: I need to achieve this task urgently

### #2 Salem_c

• void main'ers are DOOMED

Reputation: 2131
• Posts: 4,196
• Joined: 30-May 10

## Re: I need to achieve this task urgently

Posted 30 March 2013 - 02:06 AM

Say
```for ( r = 0 ; r < numberOfRows ; r++ ) {
int numberOfHashesOnThisRow = 0;  // can you figure out what value to use?
for ( h = 0 ; h < numberOfHashesOnThisRow ; h++ ) {
}
}

```

### #3 princeola

Reputation: 0
• Posts: 2
• Joined: 30-March 13

## Re: I need to achieve this task urgently

Posted 30 March 2013 - 05:10 AM

princeola, on 30 March 2013 - 12:43 AM, said:

Hi,
please I have been trying to write a code in C to prompt for # input, to create a height of 8 steps of pyramid in horizontal shapes. This is what I have tried on doing:
```# include <stdio.h>
# include <math.h>

int main (int argc, char* argv[])
{
int iterations = GetInt();

if (iterations == 8)
{
printf("iterations is 8 :)/>/>\n");
}
else
{
printf("iterations is not 8 :)/>/>\n);

for(int i = 0; i > iterations; i++)
{
printf("%d\n");
}

int i = 8;

iterations=9;

while (i => iterations)

{
printf("%d\n");

i++;

i = i + 1;

i += 1;

}
}
```

I want to achieve something like this:
#
##
###
####
#####
######
#######
########

Hi Salem_c,

I did what you said , but am getting all this errors please help me out where am wrong:

(~/Dropbox/hashes): make hashes
clang -ggdb3 -O0 -std=c99 -Wall -Werror hashes.c -lcs50 -lm -o hashes
hashes.c:13:11: error: use of undeclared identifier 'r'
for ( r = 0 ; r < number of Rows ; r++ )
^
hashes.c:13:19: error: use of undeclared identifier 'r'
for ( r = 0 ; r < number of Rows ; r++ )
^
hashes.c:13:23: error: use of undeclared identifier 'number'
for ( r = 0 ; r < number of Rows ; r++ )
^
hashes.c:13:40: error: use of undeclared identifier 'r'
for ( r = 0 ; r < number of Rows ; r++ )
^
hashes.c:15:7: error: expected expression
int = 1; r < 8;
^
hashes.c:15:16: error: use of undeclared identifier 'r'
int = 1; r < 8;
^
hashes.c:19:14: error: expected ';' at end of declaration
int number of Hashes on This Row = ;
^
;
hashes.c:23:8: error: use of undeclared identifier 'h'
for ( h = 0 ; h < number of Hashes on This ...
^
hashes.c:23:16: error: use of undeclared identifier 'h'
for ( h = 0 ; h < number of Hashes on This ...
^
hashes.c:23:51: error: use of undeclared identifier 'h'
...( h = 0 ; h < number of Hashes on This Row ; h++ )
^
hashes.c:25:4: error: expected expression
int = 1; r < 2; 1++;
^
hashes.c:25:13: error: use of undeclared identifier 'r'
int = 1; r < 2; 1++;
^
hashes.c:25:21: error: expression is not assignable
int = 1; r < 2; 1++;
~^
hashes.c:31:2: error: expected '}'
}
^
hashes.c:9:1: note: to match this '{'
{
^
14 errors generated.
make: *** [hashes] Error 1

### #4 andrewsw

• blow up my boots

Reputation: 6524
• Posts: 26,402
• Joined: 12-December 12

## Re: I need to achieve this task urgently

Posted 30 March 2013 - 05:20 AM

Quote

error: use of undeclared identifier 'r'
for ( r = 0 ; r < number of Rows ; r++ )

That error is very clear: you haven't declared r.

Why have you inserted all those spaces? Variable-names cannot contain any spaces.

This knowledge is fundamental to any programming language, so I think you need to start-over. There are tutorials here at DIC.

### #5 Salem_c

• void main'ers are DOOMED

Reputation: 2131
• Posts: 4,196
• Joined: 30-May 10

## Re: I need to achieve this task urgently

Posted 30 March 2013 - 06:34 AM

> I did what you said , but am getting all this errors please help me out where am wrong:
You blindly copy and pasted, without exercising any thought about what was going on.

It's a clue, something to make you think!