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

What is the use of ?

628


What is binary tree in c?

628


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5465


Explain 'bus error'?

565


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

2686






How to explain the final year project as a fresher please answer with sample project

473


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2245


Write a simple code fragment that will check if a number is positive or negative.

713


What is the Purpose of 'extern' keyword in a function declaration?

656


Is there a way to jump out of a function or functions?

638


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

633


How can you determine the maximum value that a numeric variable can hold?

643


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

603


Why doesn't C support function overloading?

1624


What is time null in c?

587