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 the difference between test design and test case design?

0 Answers  


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

0 Answers  


What are global variables and explain how do you declare them?

0 Answers  


How to swap two values using a single variable ? condition: Not to use Array and Pointer ?

6 Answers  


What is typedf?

0 Answers  






how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 plz plz...

3 Answers  


What are the characteristics of arrays in c?

0 Answers  


How to establish connection with oracle database software from c language?

0 Answers  


What is calloc() function?

0 Answers  


What are pointers? Why are they used?

0 Answers  


What is c programing language?

0 Answers  


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

0 Answers  


Categories