Search: | |||||

| ||||

Home » Forum » C++ Programming | RSS Feeds |

Write a program to triangle as shown below.(please help me as soon as possible)

1

2

1 3

2 4

1 3 5

2 4 6

1 3 5

2 4

1 3

2

1

Hi iman,

I tried to make triangle as you want , but due to less time i have only created it for increment part. Check code and output below.

#include <stdio.h>

#include <conio.h>

void main(){

int i,j,num,c=1,d=2,n=1;

clrscr();

printf("*****FLOYD'S TRIANGLE*****\n\n");

printf("Enter number upto which u want to generate : ");

scanf("%d",&num);

for(i=c;i<=num;){

c=1;

d=2;

for(j=1;j<=i;j++){

if(n == 1)

{

printf("%5d ",c);

c = c+2;

}

if(n == 0)

{

printf("%5d ",d);

d = d + 2;

}

if(c > num || d > num)

{

goto out;

}

}

printf("\n");

if(n == 1)

n = 0;

else

n = 1;

if(n == 1)

i++;

}

out:

getch();

}

Output

1

2

1 3

2 4

1 3 5

2 4 6

I will try for the decrement part when i will get time.

Hope this helps you.

Didn't find what you were looking for?
Find more on triangle of numbers,:-( i owe you one
Or get search suggestion and latest updates.

Related Topics:

- Drawing triangles using a form
- how can u make a triangle
- Write this text out as a triangle
- My Java doesn't load...I get the square, circle, and triangle box
- triangle of stars
- Prints to console a triangle composed by N rows using “*” chars.
- Print a triangle to console (2)
- Code of String Triangle in Assembly language
- Code of String Triangle in Assembly language
- A triangle with $ spaces inside
- pascal triangle
- Print String as Right Triangle
- Converting a "Stringed" Number to a Number
- Converting a "Stringed" Number to a Number
- Macros to print one record(one row) at a time
- Depth first search and Breath first search ...
- Depth first search and Breath first search
- Write a c++ program that will create a triangle base on user input?
- perfect number
- How to truncate a floating number?
- Read integer number
- Display character which appears number of time equal half of maximum time
- sum of series of natural numbers
- prime number
- assembly program that reads an integer number (from 0 to 9).