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
Explain the difference between getch() and getche() in c?
Tell me when is a void pointer used?
What are derived data types in c?
Explain the difference between call by value and call by reference in c language?
How can I swap two values without using a temporary?
Why is event driven programming or procedural programming, better within specific scenario?
What does nil mean in c?
Explain the term printf() and scanf() used in c language?
What is malloc() function?
What is the difference between constant pointer and constant variable?
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
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.
Explain how can I avoid the abort, retry, fail messages?
Here is a neat trick for checking whether two strings are equal
Explain what is the purpose of "extern" keyword in a function declaration?