ccplusplus.com
Learn C, C++ Concepts
Friday, October 21, 2011
print triangle of numbers in reverse pattern
/************************************************************* * File : triangle-of-numbers-in-reverse-pattern.c * Author : Saurabh Gupta * Desc : Program to print triangle of numbers in reverse * pattern in C Programming * Source : http://saurabhgupta0527.blogspot.com/p/c.html * Created : AM 09:00 21 October 2011 ************************************************************/ #include <stdio.h> int main() { int i, nTriangleNumbers, j; printf("Enter the number of values : "); scanf("%d",&nTriangleNumbers); for(i = nTriangleNumbers; i >= 1; i--) { for(j=1;j<=i;j++){ printf("%d ",j); } printf("\n"); } return 0; } /* * OUTPUT * [sgupta@rhel54x64 c]$ gcc triangle-of-numbers-in-reverse-pattern.c -o triangle-of-numbers-in-reverse-pattern [sgupta@rhel54x64 c]$ ./triangle-of-numbers-in-reverse-pattern Enter the number of values : 5 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 [sgupta@rhel54x64 c]$ */
See also
Other popular tricky C Sample Codes and language Concept
.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment