1. ## last resort

i tried everything, i guest is not enough :-) if some one willing to help i appreciated
this is the one of so many trial i have done. but still doesn't work
Code:
#include <stdio.h>
main()
{
int a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0, i=0, j=0, what = 0;

c = 10;
e = 6;
g = 2;
j = 1;

while (what<10 )
{

if (a == 0,b && c != 0)
a = b + c;

if (b == 0,a && c != 0 || d && e != 0)
b = d + e;
b = a - c;

if (c == 0,e && f != 0 || a && b != 0)
c = e + f;
c = a - b;

if (d == 0,g && h != 0 || b && e != 0)
d = g + h;
d = b - e;

if (e == 0,h && i != 0 || b && d != 0 || c && f != 0)
e = h + i;
e = c - f;
e = b - d;

if (f == 0,i && j != 0 || c && e !=0 || f && j != 0)
f = i + j;
f = c - e;

if (g == 0,d && h != 0)
g = d - h;

if (h == 0,d && g != 0 || e && i !=0)
h = e - i;
h = d - g;

if (i == 0,e && h != 0 || f && j !=0)
i = e - h;
i = f - j;

if (j == 0,f && i != 0)
j = f - i;

what++;

printf("\n         %d  \n", a);
printf("\n      %d     %d  \n", b, c);
printf("\n   %d     %d     %d     \n", d, e, f);
printf("\n%d     %d     %d      %d \n", g, h, i, j);

}

}

2. What is your program supposed to do?

3. Don't give us that "tried everything" nonsense. You've tried everything except actually looking up how to use the various operators etc that you are using - the only thing that would have actually been useful. You've just randomly typed in stuff hoping to hit the correct syntax by accident. You can't program like that. You have to actually learn how to use the stuff that you need to use.

Every single one of those if-statements probably wont do what you expect. Go and look up how to use the && operator, and learn how to use a statement block so that you can include multiple statements after an if-statement. Learn about when it makes sense to use the comma operator - hint: not in this program.

Last but not least: How the hell are we supposed to know what your program should do?!?! It might work perfectly if all it's supposed to do is output a pyramid of uninteresting numbers.

4. thanks for the advise, but i did try everything that i know but it seams i don't know enough, the program is a pyramid that the top number is the sum of the 2 numbers below it. but some of the number is known, and can put in various place in the pyramid. and can some one tell me also how to write flow chart for it
@iMAc i will look at the && operator again, please keep helping me thanks.
thanks again if u have any other suggestion please don't hesitate.

5. Originally Posted by juiceceri
thanks again if u have any other suggestion please don't hesitate.
Why would any body will hesitate dude to help you out if you write a program which can be read. There are loads of compile time errors there. You are telling us what you want to do. Means a logic but your C/C++ syntax even are not correct at each and every line i think. What iMac is telling try to learn how if statement and operators work. Learn those things and try to improve the code and then post it here

6. it's working if i enter the value for (a,b,e,g,h) but why it's not working if i change the value to (c,e,g,i) why do i have zero, is it because the while loop?
Code:
#include <stdio.h>
main()
{
int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0 ;
char what='?';

a = 32;
b = 16;
e = 8;
g = 4;
j = 4;

/*	c = 10;
e = 6;
g = 2;
j = 1;
*/

/*printf("\n         %c  \n", a);
printf("\n      %c     %c  \n", b, what);
printf("\n   %c     %c     %c     \n", what, e, what);
printf("\n%c     %c     %c      %c \n", g, what, what, j);*/

while (!(a&&b&&c&&d&&e&&f&&g&&h&&i&&j))
{

// first triangle
if(b&&c )
a = b + c;
if(a&&c )
b = a - c;
if(a&&b )
c = a - b;

//second triangle
if(d&&e )
b = d + e;
if(b&&e )
d = b - e;
if(b&&d )
e = b - d;

// third triangle
if(e&&f )
c = e + f;
if(c&&f )
e = c - f;
if(c&&e )
f = c - e;

// forth triangle
if(g&&h )
d = g + h;
if(d&&h )
g = d - h;
if(d&&g )
h = d - g;

// fifth triagle
if(h&&i )
e = h + i;
if(e&&i )
h = e - i;
if(e&&h )
i = e - h;

// sixth triangle
if(i&&j )
f = i + j;
if(f&&j )
i = f - j;
if(f&&i )
j = f - i;

printf("\n         %d  \n", a);
printf("\n      %d     %d  \n", b, c);
printf("\n   %d     %d     %d     \n", d, e, f);
printf("\n%d     %d     %d      %d \n", g, h, i, j);

getchar ();
}

}