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

Which is better oop or procedural?

0 Answers  


What does the error 'Null Pointer Assignment' mean and what causes this error?

0 Answers   TISL,


How do we open a binary file in Read/Write mode in C?

0 Answers   Alter,


Write a program to generate the first n terms in the series --- 9,11,20,31,...,82

1 Answers   Cognizant,


Explain do array subscripts always start with zero?

0 Answers  






write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

0 Answers   Wipro,


main() { int a[3][4] ={1,2,3,4,5,6,7,8,9,10,11,12} ; int i, j , k=99 ; for(i=0;i<3;i++) for(j=0;j<4;j++) if(a[i][j] < k) k = a[i][j]; printf("%d", k); }

4 Answers   Vector, Wipro, Zoho,


What is pragma c?

0 Answers  


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 a stack

3 Answers  


Why do we use stdio h and conio h?

0 Answers  


Explain how can a program be made to print the name of a source file where an error occurs?

0 Answers  


Categories