code snippet for creating a pyramids triangle
ex

1
2 2
3 3 3

Answers were Sorted based on User's Feedback



code snippet for creating a pyramids triangle ex 1 2 2 3 3 3..

Answer / vignesh1988i

A SMALL IMPLEMENTATION OF POINTERS

#include<stdio.h>
#include<conio.h>
void main()
{
int n,*p,*q;
printf("enter the number of lines :");
scanf("%d",&n);
for(int i=1,p=&i;*p<=n;*p++)
{
printf("\n");
for(int j=1,q=&j;*q<=*p;*q++)
{
printf("%d",*p);
printf(" ");
}
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No

code snippet for creating a pyramids triangle ex 1 2 2 3 3 3..

Answer / manvi

main()
{
int i,j,n;
printf("enter the limit");
scanf("%d",&n);
for(i=1;i<=n;i++)
{

for(j=0;j<i;j++)
{
printf("%d",i);
}
printf("\n");
}

}

Is This Answer Correct ?    1 Yes 0 No

code snippet for creating a pyramids triangle ex 1 2 2 3 3 3..

Answer / k

#include<iostream.h>
int main()
{int i,j,k;
for(i=1;i<=3;i++)
{cout<<"\n";
for(j=1;j<=3-i;j++)
cout<<" ";
for(k=i;k>0;k--)
cout<<i<<" ";
}
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

code snippet for creating a pyramids triangle ex 1 2 2 3 3 3..

Answer / rajesh kamar s

void main()

{
int n,i,j;
printf("enter the num of rows\t:");
scanf("%d",&n);

for(i=1;i<=n;i++)
{
for(int k=0;k<n-i;k++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d ",i);
printf("\n");
}
}

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

Do you know null pointer?

0 Answers  


main is a predefined or user define function if user defined why? if predefined whay?

12 Answers   TCS,


What is typedef?

1 Answers  


Why is a semicolon (;) put at the end of every program statement?

0 Answers  


which of the function operator cannot be over loaded a) <= b)?: c)== d)*

10 Answers   Cisco, CTS, Google, HCL, HP,






wap in c to accept a number display the total count of digit

4 Answers  


What are the types of c language?

0 Answers  


How to get string length of given string in c?

0 Answers  


What is the diffences between Windows XP and Windows Visa

1 Answers   Aricent, FHF,


can u write a program in C, which does not use = (eqaul)or any arithmatic assignment(like -=,+=,*= etc) operator to swap to number?

2 Answers  


What is a lookup table in c?

0 Answers  


difference between loading and linking

1 Answers  


Categories