×
ALL THE HUSTLE, LATE NIGHTS, MISSED PARTIES, EARLY MORNINGS WILL BE WORTH IT.
--Your friends at LectureNotes
Close

Lab Manuals for C Language - C By Umesh Kumar

  • C Language - C
  • Practical
  • 202 Views
  • 7 Offline Downloads
  • Uploaded 2 months ago
Umesh Kumar
Umesh Kumar
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

CODE FOR PROGRAMMING IN C Pattern programs in C Pattern programs in C language: These programs print various patterns of numbers and stars. These codes illustrate how to create various patterns using C programming. The C programs involve usage of nested for loops (a for loop inside a for loop). A pattern of numbers, star or characters is a way of arranging these in some logical manner or they may form a sequence. Some of these patterns are triangles which have special importance in mathematics. Some patterns are symmetrical while others are not. Please see the complete page and look at comments for many different patterns. 1. Program to print pyramid pattern in C : Pattern 1 ***** ***** ***** ***** ***** #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=0; i<5; i++) { for(j=0; j<5; j++) { printf(" * "); } printf("\n"); } getch(); } By Mr. UMESH KUMAR, MCA (GGU) Page | 1 Department of computer science and information technology

Text from page-2

CODE FOR PROGRAMMING IN C 2. Program : Program to print pyramid pattern in C : Pattern 2 * ** *** **** ***** #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=0; i<5; i++) { for(j=0; j<=i; j++) { printf(" * "); } printf("\n"); } getch(); } 3. Program :Program to print pyramid pattern in C : Pattern 3 * ** *** **** ***** #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=5; j>=i; j--) { printf(" "); } for(k=1; k<=i; k++) { printf("*"); } printf("\n"); } getch(); } By Mr. UMESH KUMAR, MCA (GGU) Page | 2 Department of computer science and information technology

Text from page-3

CODE FOR PROGRAMMING IN C 4. Program :Program to print pyramid pattern in C : Pattern 4 ***** **** *** ** * #include <stdio.h> #include <conio.h> void main() { int i,j,k,samp=1; clrscr(); for(i=5; i>=1; i--) { for(k=samp; k>=0; k--) { printf(" "); // only 1 space } for(j=i; j>=1; j--) { printf("*"); } samp = samp + 1; printf("\n"); } getch(); } or #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=5; j>=i; j--) { printf("*"); } for(k=1; k<=i; k++) { printf(" "); } printf("\n"); } getch(); } By Mr. UMESH KUMAR, MCA (GGU) Page | 3 Department of computer science and information technology

Text from page-4

CODE FOR PROGRAMMING IN C 5. Program : Program to print pyramid pattern in C : Pattern 5 ***** **** *** ** * #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=5; i>=1; i--) { for(j=1; j<=i; j++) { printf(" * "); } printf("\n"); } getch(); } 6. Program : Program to print pyramid pattern in C : Pattern 6 * ** *** **** ***** #include <stdio.h> #include <conio.h> void main() { int i,j,k,t=0; clrscr(); for(i=1; i<=5; i++) { for(k=t; k<5; k++) { printf(" "); } for(j=0; j< i; j++) { printf(" * "); t = t + 1; } printf("\n"); By Mr. UMESH KUMAR, MCA (GGU) Page | 4 Department of computer science and information technology

Lecture Notes