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

write a c program to find the square of a 5 digit number and print the result.

5 Answers   Accenture, Sasken, Vimukti Technologies,


Why static is used in c?

0 Answers  


program to find the roots of a quardratic equation

1 Answers  


Do you know the use of 'auto' keyword?

0 Answers  


What is a sequential access file?

0 Answers  






When is an interface "good"?

1 Answers  


WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h> #include<conio.h> void main() { int k=20; printf("%d%d%d%d",k,k++,++k,k); getch(); }

25 Answers  


fn f(x) { if(x<=0) return; else f(x-1)+x; }

5 Answers   HCL,


write C code to reverse a string such that if i/p is "abc defg hij klmno pqrs tuv wxyz" and the o/p should be "cba gfed jih onmlk srqp vut zyxw"

2 Answers  


what is the use of call back function in c?tell me with example

2 Answers   Bosch,


What is header file definition?

0 Answers  


The code is::::: if(condition) Printf("Hello"); Else Printf("World"); What will be the condition in if in such a way that both Hello and world are printed in a single attempt?????? Single Attempt in the sense... It must first print "Hello" and it Must go to else part and print "World"..... No loops, Recursion are allowed........................

14 Answers   HOV Services, IBM, Potty,


Categories