Write a program in c to print
1
121
12321
1234321
123454321

Answers were Sorted based on User's Feedback



Write a program in c to print 1 121 12321 1234321 1234..

Answer / mohammedayub.y(c.i.e.t)

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n,k;
printf("enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=n;k>i;k--)printf(" ");
for(j=1;j<=i;j++)
{
printf("%d",j);
}
if(i>1)
{
for(j=i;j>1;j--)
{
printf("%d",j-1);
}
}
printf("\n");
}

getch();
return 0;
}

Is This Answer Correct ?    72 Yes 28 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / sahil and dipanshu

#include<stdio.h>
#include<iostream.h>

int main()
{
int i,j,k,num;
num=5;
for(i=1;i<=num;i++)
{
for(j=1;j<num-i;j++)
{
cout<<" ";
}
for(k=1;k<=i;k++)
{
cout<<k;
}
for(k=i;k>1;k--)
{
cout<<k-1;
}
cout<<endl;
}
return 0;
}

Is This Answer Correct ?    21 Yes 8 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / sabby

#include<stdio.h>
main()
{
int i,j,s,n;
printf("Enter the number of rows:");
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
for(s=1;s<=n-i;s++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
j=j-2;
for(;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}

Is This Answer Correct ?    16 Yes 7 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / arun c s

#include <stdio.h>
main()
{
int i, j, k, space, n=9;

for (i=1; i<=n; i++)
{
for (j=1; j<=n-i; j++)
putchar(' ');
for (j=1,k=2*i-1; j<=2*i-1; j++,k--)
{
if (j <= k)
printf("%d", j);
else
printf("%d", k);
}
putchar('
');
}

getch();
}

Is This Answer Correct ?    4 Yes 3 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / rohit1729

#include<iostream>
using namespace std;
int main()
{
int i,j,k,t,n,c,a[20];
cin>>t;
for(k=0;k<20;k++)
a[k]=(k+1);
while(t--)
{
cin>>n;
for(i=0;i<n;i++)
{
c=i-1;
for(j=0;j<(2*i+1);j++)
{
if(i>=j)
cout<<a[j];
else
{
cout<<a[c];
c--;
}
}cout<<" ";
}cout<<endl;
}
return 0;
}

Is This Answer Correct ?    2 Yes 1 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / rahim

int i, j, k, num = 5;
cout << "number u1=";


cin >> num;
for (i = 1; i <= num; i++)
{
for (j = 1; j <= num - i; j++)
{
cout << " ";
}
for (k = 1; k < i; k++)
{
cout << k;

}
for (k = i; k >= 1; k--)
{
cout << k;
}

cout << endl;
}

//----------------------------------------
for (i = num; i >= 1; i--)
{
for (j = 1; j <= num - i; j++)
{
cout << " ";
}
for (k = 1; k < i; k++)
{
cout << k;

}
for (k = i; k >= 1; k--)
{
cout << k;
}

cout << endl;
}

Is This Answer Correct ?    1 Yes 1 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / smita adhikari

a = 1
FOR i = 1 TO 5
PRINT a * a
a = a * 10 + 1
NEXT i
END

Is This Answer Correct ?    1 Yes 1 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / roshan patil

#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k,num;
cout<<num;
for(i=1;i<=num;i++)
{
for(j=1;j<num-1;j++)
{
cout<<" ";
}
for(k=1;k<i;k++)
{
cout<<k;
}
for(k=i;k>=1;k--)
{
cout<<k;
}
}
}

Is This Answer Correct ?    12 Yes 14 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / durai

int a, b;
for( a=1;i<=5;a++)
{
for(b=1;b<=(2*a-1);b++)
{ if(b<=a)
printf b;
else
printf(2*a-b);
}
printf
;
}

Is This Answer Correct ?    0 Yes 5 No

Write a program in c to print 1 121 12321 1234321 1234..

Answer / ayas kumar das

#include"stdio.h"
int main()
{
int i,j,n;
printf("enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
if(i>1)
{
for(j=i;j>1;)
{
printf("%d",j-1);
j=j-1;
}
}
printf("\n");
}
return 0;
}

Is This Answer Correct ?    12 Yes 20 No

Post New Answer

More C Interview Questions

cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

0 Answers  


write a function that accepts an array A with n elements and array B with n-1 elements. Find the missing one in array B,with an optimized manner?

2 Answers   Zensar,


what will be the output of this program? #include<stdio.h> #define cube(x) x*x*x void main() { int i,j=5; i=cube(j+3); printf("i=%d",i); }

6 Answers   IBM,


What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack

6 Answers  


What is an auto variable in c?

0 Answers  






What is unsigned int in c?

0 Answers  


Write a C Program to display the following menu: Menu 1. Display 2. Copy 3. Append 4. Exit Accept the choice (1-4) from the user, and perform the following tasks: Choice 1: Accept a file name from the user and display the file on screen Choice 2: Accept two file names, and copy first file to the second Choice 3: Accept two file names, and append second file to the first file Choice 4: Terminate the program

1 Answers   Accenture, Concor, DMU, Satyam, Syntel, Tora,


Explain what is meant by 'bit masking'?

0 Answers  


how to find sum of 5 digits in C?

4 Answers  


Write a program of advanced Fibonacci series.

0 Answers   Aspiring Minds,


List some applications of c programming language?

0 Answers  


count the numbers between 100 and 300, that star with 2 and ends with 2

5 Answers   Mind Tree,


Categories