Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a pgm to print
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1

Answers were Sorted based on User's Feedback



write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / nisrar

void main()
{
int i,j,k,m;
for(i=1;i<=4;i++)
{
for(j=4;j>i;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
for(m=i;m>1;m--)
{
printf("%d",m-1);
}
printf("\n");
}
}

Is This Answer Correct ?    7 Yes 0 No

write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / siva kumar kalamraju

#include <stdio.h>
void fun(int num)
{
int i;
int max=1,spaces=0;

spaces=num*2;

while(max<=num)
{

for(i=1;i<=spaces;i++)
{
printf(" ");
}
for(i=1; i<=max; i++)
printf("%d ",i);
for(i=(max-1);i>0;i--)
printf("%d ",i);
printf("\n",i);
max++;
spaces=spaces-2;
}
//recursivefun(max+1);
}

int main()
{
int Number;
printf("Enter a Number:");
scanf("%d",&Number);
fun(Number);

getch();
}

Is This Answer Correct ?    5 Yes 4 No

write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / nisrar

void main()
{
int i,j,k,m;
for(i=1;i<=4;i++)
{
for(j=4;j>i;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
for(m=i;m>1;m--)
{
printf("%d",m-1);
}
printf("\n");
}
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a<b,printb.find the sum digits of that number & then print.if a==b multiply 10 with a & add 20 with b store in c and then print

0 Answers  


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

0 Answers   TCS,


What is indirection? How many levels of pointers can you have?

0 Answers   Aspire, Infogain,


What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these

3 Answers   IBM,


What is the difference between arrays and pointers?

0 Answers  


Which function in C can be used to append a string to another string?

0 Answers  


What is meant by int fun const(int a, int b) { .... ... }

1 Answers  


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


Explain #pragma in C.

1 Answers  


write a program to find the sum of the array elements in c language?

24 Answers   ICT, Infosys, Wipro,


for (i <= 5 && i >= -1;++i; i > 0) { printf("%d ", i); }

1 Answers  


Hi, main() { } Is a user defined function or Built in Functionn

26 Answers   Honeywell, Yahoo,


Categories