ccplusplus.com
Learn C, C++ Concepts
Tuesday, September 13, 2011
print triangle of numbers in c
/****************************************************** * File : print-triangle-of-numbers.c * Author : Saurabh Gupta * Desc : prints triangle of numbers in reverse * order * Source : http://saurabhgupta0527.blogspot.com/ * Created : AM 10:14 13 September 2011 *****************************************************/ #include <stdio.h> int main() { int i, nNumberCount, j; printf("\nGive The Value of Number of numbers: "); scanf("%d", &nNumberCount); printf ("\n"); for(i = nNumberCount; i >= 1; i--) { for(j = 1; j <= i; j++) { printf("%d ",j); } printf("\n"); } return 0; } /* * * [sgupta@rhel54x64 c]$ gcc print-triangle-of-numbers.c -o print-triangle-of-numbers [sgupta@rhel54x64 c]$ ./print-triangle-of-numbers Give The Value of Number of numbers: 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 [sgupta@rhel54x64 c]$ */
See Also
Various other Popular C codes and C topics
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment