i want the code for printing the output as follows

4 4
3 3
2 2
1 1
0
1 1
2 2
3 3
4 4

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int m,i,j;
printf("enter the max. number for the series :");
scanf("%d",&m);
for(i=m;i<=0;i--)
{
for(j=0;j<m-i;j++)
printf(" ");
printf("%d",i);
for(j=1;j<=(2*m-(m-i+1+(m-i)));j++)
printf(" ");
printf("%d",i);
printf("\n");
}
i++;
j=m-1;
for(;i<=m;i++)
{
for(;j>(m-i);j--)
printf(" ");
printf("%d",i);
for(j=1;j<(2*i);j++)
printf(" ");
printf("%d",i);
printf("\n");
}
getch();
}

thank u

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between getch() and getche() in c?

645


Tell me when is a void pointer used?

753


What are derived data types in c?

704


Explain the difference between call by value and call by reference in c language?

753


How can I swap two values without using a temporary?

702






Why is event driven programming or procedural programming, better within specific scenario?

2044


What does nil mean in c?

780


Explain the term printf() and scanf() used in c language?

692


What is malloc() function?

725


What is the difference between constant pointer and constant variable?

842


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

778


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2337


Explain how can I avoid the abort, retry, fail messages?

685


Here is a neat trick for checking whether two strings are equal

659


Explain what is the purpose of "extern" keyword in a function declaration?

719