ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
code snippet for creating a pyramids triangle
ex

     1
   2   2
 3   3   3
 Question Submitted By :: Shiva034
I also faced this Question!!     Rank Answer Posted By  
 
  Re: code snippet for creating a pyramids triangle ex 1 2 2 3 3 3
Answer
# 1
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
Rajesh Kamar S
 
  Re: code snippet for creating a pyramids triangle ex 1 2 2 3 3 3
Answer
# 2
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 ?    1 Yes 1 No
Vignesh1988i
 
 
 
  Re: code snippet for creating a pyramids triangle ex 1 2 2 3 3 3
Answer
# 3
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
Manvi
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How do you write a program which produces its own source code as its output?  2
to find out the reverse digit of a given number Infosys5
main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain  1
what is the difference between normal variables and pointer variables.............. Satyam7
who will call your main function in c under linux?  2
write a program for even numbers?  8
what is call by value and call by reference  2
Can we include one C program into another C program if yes how? Infosys4
what will happen if you free a pointer twice after allocating memory dynamically ? Novell2
what are the various memory handling mechanisms in C ? HP3
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]  4
class foo { public: static int func(const char*& p) const; }; This is illegal, why? Google6
what is the difference between. system call and library function? CDAC2
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]  2
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack  5
hat is a pointer? Assurgent3
what is mallloc()?how it works? Excel3
Which of the following about automatic variables within a function is correct ? a.its type must be declared before using the variable b.they are local c.they are not initialised to zero d.they are global. TCS3
program to find a smallest number in an array Microsoft5
void swap(int a,int b) { a=a+b; b=a-b; a=a-b; } in this code always gives the same result for all case TCS7
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com