HACKERS UNDERGROUND © 2012 BY RISHABH SHARMA

Friday, 13 January 2012

Asterisks Programming in C

Asterisks Programming in C TYPE- 1

/*This is a 'C'program which print the following
Asterisk pattern as output:- *
                 **
                 ***
                 ****
                 ***** & so on*/
#include<stdio.h>
#include<conio.h> //header files
void main()
{
int i,j,n; //variables
clrscr();
printf("Enter the number of lines upto which the pattern will print[natural number only]:");
scanf("%d",&n);
for(i=1;i<=n;i++)//start of loop.This loop control the row of pattern print
{
for(j=1;j<=i;j++)//nested loop.This loop print the asterisk of pattern.
printf("*");
printf("\n");//This statement is use to change row of the pattern.
}//end of loop
getch();
}//end of program


Asterisks Programming in C TYPE- 2




/*This is a 'C'program which print the following
Asterisk pattern as output:-     *
                **
                   ***
                  ****
                 ***** & so on*/
#include<stdio.h>
#include<conio.h> //header files
void main()
{
int i,j,n,k; //variables
clrscr();
printf("Enter the number of lines upto which the pattern will print[natural number only]:");
scanf("%d",&n);
for(i=1;i<=n;i++)//start of loop.This loop control the row of pattern print.
{
for(k=1;k<=n-i;k++)//nested loop.This loop control the space of pattern.
printf(" ");
for(j=1;j<=i;j++)//nested loop.This loop print the asterisk of pattern.
printf("*");
printf("\n");//This statement is use to change row of the pattern.
}//end of loop
getch();
}//end of program


Asterisks Programming in C TYPE- 3



 /*This is a 'C'program which print the following
 Asterisk pattern as output:-
 *                 *
 **             **
 ***         ***
 ****     ****
 *********** & so on*/
 #include<stdio.h>
 #include<conio.h> //header files
 void main()
 {
 int i,j,n,k; //variables
 clrscr();
 printf("Enter the number of lines upto which the pattern will print[natural number only]:");
 scanf("%d",&n);
 for(i=1;i<=n;i++)//start of loop.This loop control the row of pattern print.
 {
 for(j=1;j<=i;j++)//nested loop.This loop print the left side asterisk of pattern.
 printf("*");
 for(k=1;k<=2*(n-i);k++)//nested loop.This loop control the space between asterisk pattern.
 printf(" ");
 for(j=1;j<=i;j++)//nested loop.This loop print the right side asterisk of pattern.
 printf("*");
 printf("\n");//This statement is use to change row of the pattern.
 }//end of loop
 getch();
 }//end of program


Asterisks Programming in C TYPE- 4



/*This is a 'C'program which print the following
Asterisk pattern as output:-
**********
 ****  ****
  ***    ***
   **      **
    *        * & so on*/
#include<stdio.h>
#include<conio.h> //header files
void main()
{
int i,j,n,k; //variables
clrscr();
printf("Enter the number of lines upto which the pattern will print[natural number only]:");
scanf("%d",&n);
for(i=n;i>=1;i--)//start of loop.This loop control the row of pattern print.
{
for(j=1;j<=i;j++)//nested loop.This loop print the left side asterisk of pattern.
printf("*");
for(k=1;k<=2*(n-i);k++)//nested loop.This loop control the space between asterisk pattern.
printf(" ");
for(j=1;j<=i;j++)//nested loop.This loop print the right side asterisk of pattern.
printf("*");
printf("\n");//This statement is use to change row of the pattern.
}//end of loop
getch();
}//end of program



Asterisks Programming in C TYPE- 5


/*This is a 'C'program which print the following
Asterisk pattern as output:- *
                 **
                 ***
                 ****
                 *****
                 ****
                 ***
                 **
                 * & so on*/
#include<stdio.h>
#include<conio.h> //header files
void main()
{
int i,j,n; //variables
clrscr();
printf("Enter the number of lines upto which the pattern will print[natural number only]:");
scanf("%d",&n);
for(i=1;i<=n;i++)//start of first loop(use for incresing of number of asterisk).This loop control the row of pattern print.
{
for(j=1;j<=i;j++)//nested loop.This loop print the asterisk of pattern.
printf("*");
printf("\n");//This statement is use to change row of the pattern.
}//end of first loop
for(i=(n-1);i>=1;i--)//start of second loop(use for decresing of number of asterisk).This loop control the row of pattern print
{
for(j=1;j<=i;j++)//nested loop.This loop print the asterisk of pattern.
printf("*");
printf("\n");//This statement is use to change row of the pattern.
}//end of second loop
getch();
}//end of program

post by rishabh sharma hackersunderground

0 comments:

Post a Comment

 
Design by HACKERS UNDERGROUND
HACKERS UNDERGROUND © 2012 BY RISHABH SHARMA