program to print following pattern
#include<stdio.h>
#include<conio.h>
int abs(int);
main()
{
int n,x=0,i,j,k=0,t=0;
printf("Enter number of lines");
scanf("%d",&n);
for(i=0;i<n;i++)
{k=(-1)*t;
for(j=n-i;j>0;j--)
{
printf(" ");
}
while(k<=t)
{
printf("%d",abs(k));
k++;
}
t++;
printf("\n");
}
getch();
}
int abs(int x)
{
if(x<0)
return (-1)*x;
else
return x;
}
#include<stdio.h>
#include<conio.h>
int abs(int);
main()
{
int n,x=0,i,j,k=0,t=0;
printf("Enter number of lines");
scanf("%d",&n);
for(i=0;i<n;i++)
{k=(-1)*t;
for(j=n-i;j>0;j--)
{
printf(" ");
}
while(k<=t)
{
printf("%d",abs(k));
k++;
}
t++;
printf("\n");
}
getch();
}
int abs(int x)
{
if(x<0)
return (-1)*x;
else
return x;
}
program to print following pattern
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,l,n,counter;
printf("enter number of rows");
scanf("%d",&n);
l=n;
for(j=1;j<=n;j++){
for(i=1;i<l;i++)
printf(" ");
for(counter=0;counter<2*j;counter++)
{
if(counter%2==0)
printf("*");
else
printf(" ");
}
l--;
printf("\n");
}
getch();
}
No comments:
Post a Comment