Abbdbd

Only available on StudyMode
  • Download(s) : 57
  • Published : December 3, 2012
Open Document
Text Preview
COMPUTER PROGRAMMING
ASSIGNMENT

NAME: MEHR-UN-NISA
ROLL NUMBER: SP12-BET-037
DATE: 23/10/2012
SUBMITTED TO: SIR USMAN YASEEN

Write the following programs that takes the size as an integer from the user and displays the shapes (given below) with the help of asterisks. 1. Size=7(base and perpendicular have 7 asterisk)
*
**
***
****
*****
******
*******
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n;

printf("enter number");
scanf("%d",&n);
for(i=1; i<=7; i++)
{
for(j=0; j<i; j++)
printf("*");
printf("\n");
}
getch();
return 0;
}

2. Size=7(base and perpendicular have 7asterik)
*
**
***
****
*****
******
*******
PROGRAM:
#include <stdio.h>
#include <conio.h>
int main ()
{
int i,j,k,l,n;
printf ("enter size");
scanf ("%d",&n);
l=n-1;
for (i=0;i<=n;i++)
{
for (k=l;k>=i;k--)
{
printf(" ");
}
for (j=0;j<=i-1;j++)
{
printf ("*");
}
printf ("\n");
}
getch();
return 0;
}

3. Size=7(base and perpendicular have 7 asterisk)
*******
******
*****
****
***
**
*
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n;
printf("enter size");
scanf("%d",&n);
for(i=8; i>1; i--)
{
for(j=1; j<i; j++)
printf("*");
printf("\n");
}
getch();
return 0;
}

4. Size=7(base and perpendicular have 7 asterisk)
*******
******
*****
****
***
**
*
PROGRAM:
#include <stdio.h>
#include<conio.h>
int main()
{
int i,j,k,n;
printf("enter size");
scanf("%d",&n);
for(i=7;i>=1;i--)
{
for(j=7-i;j>=1;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
}
printf("\n");
}
getch();
return 0;
}

5. Size=7(base has 7 asterisk)
*
***
*****
*******
PROGRAM:
#include <stdio.h>
#include <conio.h>
main ()
{
int i,j,k,l,n;
printf ("enter size");
scanf ("%d",&n);
l=n-1;
for (i=0;i<=n;i++)
{
if (i%2!=0) continue;
for (k=l;k>=i;k--)
{
if (k%2!=0) continue;
printf(" ");
}
for (j=0;j<=i;j++)
{
printf ("*");
}
printf ("\n");
}
getch();
return (0);
}
tracking img