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

What is #line in c?

0 Answers  


Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer...

4 Answers   TCS,


can any one tel me wt is the question pattern for NIC exam

0 Answers   NIC,


What is the scope of an external variable in c?

0 Answers  


Is using exit() the same as using return?

0 Answers  


A.C func() { pritnf(" in fuction %d",MACRO); } MAIN.c testfunc() { #define MACRO 10 printf("in test function %d", MACRO); } main() { printf("in main %d",MACRO); func(); testfunc(); getch(); }

2 Answers   Wipro,


write a c program to find the probability of random numbers between 1-1000

0 Answers   ADS,


Dear Sir, we are required the bubble sorting programs Regs Prem

1 Answers  


Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter words-1 3-letter words-1 4-letter words-4

1 Answers   Mind Tree, TCS,


Explain what a Binary Search Tree is.

3 Answers  


What is static volatile in c?

0 Answers  


Is c easy to learn?

0 Answers  


Categories