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

What is a good way to implement complex numbers in c?

0 Answers  


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


Are local variables initialized to zero by default in c?

0 Answers  


Write a program to print "hello world" without using a semicolon?

0 Answers  


What is pointer and structure in c?

0 Answers  


While compiling a c program,graphics header files are not including in my program..eg: <graphics.h>,what may be the problem...is there any environment settings exists.

2 Answers  


What are local static variables?

0 Answers  


number 2 plssssss help !!....using array.. turbo c.. create a program that will accept a number and determine if it is a happy number or an unhappy number.. example: enter a number : 7 7*7=49 then 4 and 9 4*4 and 9*9== 16 + 18 gives you 97 then 9 and 7 9*9 and 7*7 == 81 + 49 gives you 130 then 1 and 3 1*1 and 3*3 == 1 + 9 gives you 10 1*1 gives you 1 sample output: 7= 49= 16+81= 97= 81+49=130 =1+9=10 =1 "7 is a happy number" . if the last number is 2 then the number being inputed is not a happy number.

3 Answers  


Sir i need notes for structure,functions,pointers in c language can you help me please

0 Answers   TCS,


Where does the name "C" come from, anyway?

0 Answers   Celstream,


Does sprintf put null character?

0 Answers  


What is the difference between a free-standing and a hosted environment?

0 Answers   Aspire,


Categories