>Narue can u elaborate on reasons y my code sucks as well wud fail ??
You need an explanation? Clearly you don't take pride in your own work, or you would have at least tried to compile that code before posting it. But, I'll give you the benefit of the doubt. Let's make your code compilable and then presentable (note that I made no changes to your logic, though I assumed by !! you meant ||):
#include <stdio.h>
#include <stdlib.h>
int main ( void )
{
int i, j;
int ary[10][10], n;
printf ( "Enter the number of rows:" );
fflush ( stdout );
if ( scanf ( "%d", &n ) != 1 || n < 0 || n > 10 )
return EXIT_FAILURE;
for ( i = 0; i < n; i++ ) {
for ( j = 0; j <= i; j++ ) {
if ( j == 0 || j == 1 )
ary[i][j] = 1;
else
ary[i][j] = ary[i - 1][j - 1] + ary[i - 1][j];
}
}
for ( i = 0; i < n; i++ ) {
for ( j = 0; j <= i; j++ )
printf ( "%-6d", ary[i][j] );
printf ( "\n" );
}
return EXIT_SUCCESS;
}
And the output on my system is (drumroll please):
Enter the number of rows: [B]10[/B]
1
1 1
1 1 1244889
1 1 12448904730113
1 1 124489159750038203521
1 1 12448927219894141785248203648
1 1 1244893846478621398418223821728203648
1 1 124489497096792986320443780590305858208203648
1 1 124489510954573395728837364379474366410387894689588966
1 1 12448961219946850527456113216677148010204113155878483784349588968
That's certainly a different way of displaying Pascal's triangle. Compare that with a correct program:
#include <stdio.h>
#include <stdlib.h>
int main ( void )
{
int i, j;
int n;
printf ( "Enter the number of rows: " );
fflush ( stdout );
if ( scanf ( "%d", &n ) != 1 || n < 0 || n > 10 )
return EXIT_FAILURE;
for ( i = 0; i < n; i++ ) {
int result = 1;
for ( j = 0; j < n; j++ ) {
if ( j > 0 )
result = result * ( i + j ) / j;
printf ( "%-6d", result );
}
printf ( "\n" );
}
return EXIT_SUCCESS;
}
And you get a more recognizable table:
Enter the number of rows: [B]10[/B]
1 1 1 1 1 1 1 1 1 1
1 2 3 4 5 6 7 8 9 10
1 3 6 10 15 21 28 36 45 55
1 4 10 20 35 56 84 120 165 220
1 5 15 35 70 126 210 330 495 715
1 6 21 56 126 252 462 792 1287 2002
1 7 28 84 210 462 924 1716 3003 5005
1 8 36 120 330 792 1716 3432 6435 11440
1 9 45 165 495 1287 3003 6435 12870 24310
1 10 55 220 715 2002 5005 11440 24310 48620
>y wud it suck???????????
No, it's not that it "wud" suck, it's that it does suck. And as for why, because it's not compilable, and even if it were, it would still be wrong and broken. Is that so hard to understand?
As a side note, those dumbass abbreviations don't make you look any smarter. This isn't a chatroom, where slow typers need to abbreviate everything to get their message posted in time. Take your time, use correct spelling and grammer, and people will respect you more for it.