Showing posts with label 4 434 43234 4321234 43234 434 4 diamond C program. Show all posts
Showing posts with label 4 434 43234 4321234 43234 434 4 diamond C program. Show all posts

7.03.2013

Diamond Pattern C program

Q. Write a C program to print the following diamond pattern as:

4
434
43234
4321234
43234
434
4

Ans.

/*c program for diamond pattern*/
#include<stdio.h>
int main()
{
 int num,r,c,z,n,nm,no;
 printf("Enter max. number : ");
 scanf("%d", &num);
 nm = num+1;
 for(r=1; r<=num; r++,nm--)
 {
  for(c=1,n=num; c<=r; c++,n--)
     printf("%d",n);
  for(z=nm,c=1; c<r; c++,z++)
     printf("%d",z);
  printf("\n");
 }