Vous êtes sur la page 1sur 12

[Pick the date]

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.

Regards: SharadKGupta (Sharad Kumar Gupta, Moradabad, India)


1. Write a program to print the following triangle pattern in C language.

* * ***

NINE Triangle Programs In C- SharadKGupta

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"); } }

2. Write a program to print the following triangle pattern in C language.

***** **** ***

NINE Triangle Programs In C- SharadKGupta

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.

* ** ***

NINE Triangle Programs In C- SharadKGupta

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"); } }

NINE Triangle Programs In C- SharadKGupta

Page 5

4. 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<=i; j++) { printf ("%d",i); } printf ("\n"); } }

NINE Triangle Programs In C- SharadKGupta

Page 6

5. Write a program to print the following triangle pattern in C language.

55555 4444 333 22 1


C SOURCE CODE

#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"); } }

NINE Triangle Programs In C- SharadKGupta

Page 7

6. 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<=i; j++) { printf ("%d",j); } printf ("\n"); } }

NINE Triangle Programs In C- SharadKGupta

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"); } }

NINE Triangle Programs In C- SharadKGupta

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"); } }

NINE Triangle Programs In C- SharadKGupta

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"); } }

NINE Triangle Programs In C- SharadKGupta

Page 11

THANK YOU FOR READING


NINE TRIANGLE PROGRAMS IN C
SharadKGupta ( Sharad Kumar Gupta ,Moradabad , India ) Email : skgupta.mbd@gmail.com Send Your Reviews to me by following subject : NINE TRIANGLE PROGRAMS IN C For Improving It.

NINE Triangle Programs In C- SharadKGupta

Page 12

Vous aimerez peut-être aussi