Académique Documents
Professionnel Documents
Culture Documents
S
[Type BY: the document subtitle] | User A BOOK - SharadKGupta
This is a comprehensive book for the c learners .The most important programs in any language is to make triangles .Thus by seeing the importance of such programs I decided to put my efforts for students and developers. They will be able to shoot out their problems and will make a solid grasp on these programs. This book is presented with illustration that contains code as well as output. All programs are tested with output so you will not have any difficulty in learning them. You can email me on skgupta.mbd@gmail.com any time.
* * ***
Page 2
**** *****
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for (j=1; j<=i; j++) { printf ("*"); } printf ("\n"); } }
Page 3
** *
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for (j=5; j>=i; j--) { printf ("*"); } printf ("\n"); } }
3. Write a program to print the following triangle pattern in C language.
* ** ***
Page 4
**** *****
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for(j=1;j<=5-i;j++) printf(" "); for (j=1; j<=i; j++) { printf ("*"); } printf ("\n"); } }
Page 5
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for (j=1; j<=i; j++) { printf ("%d",i); } printf ("\n"); } }
Page 6
#include<stdio.h> void main () { int i, j; for (i=5; i>=1; i--) { for (j=1; j<=i; j++) { printf ("%d",i); } printf ("\n"); } }
Page 7
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for (j=1; j<=i; j++) { printf ("%d",j); } printf ("\n"); } }
Page 8
7. Write a program to print the following triangle pattern in C language. 54321 4321 321 21 1
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for (j=5; j>=i; j--) { printf ("%d",j); } printf ("\n"); } }
Page 9
8 . Write a program to print the following triangle pattern in C language. 1 12 123 1234 12345
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for(j=1;j<=5-i;j++) printf(" "); for (j=1; j<=i; j++) { printf ("%d",i); } printf ("\n"); } }
Page 10
9. Write a program to print the following triangle pattern in C language. 1 22 333 4444 55555
C SOURCE CODE
#include<stdio.h> void main () { int i, j; for (i=1; i<=5; i++) { for(j=1;j<=5-i;j++) printf(" "); for (j=1; j<=i; j++) { printf ("%d",j); } printf ("\n"); } }
Page 11
Page 12