ALLInterview.com :: Home Page            
 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                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2262)
 C++ interview questions  C++ Interview Questions (1118)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (648)
Question
Write a Program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
use two nested loops.
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the lines :");
scanf("%d",&n);
for(int i=1;i<=n/2;i++)
{
printf("*\n");
for(int j=1;j<=2*i;j++)
printf("%d",j);
printf("\n");
}
if(n%2!=0)
printf("\n*");
getch();
}

thank u
 
Is This Answer Correct ?    53 Yes 29 No
Vignesh1988i
 
Answer
# 2
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the lines :");
scanf("%d",&n);
for(int i=1;i<=n/2;i++)
{
printf("*\n");
for(int j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");
getch();
}
 
Is This Answer Correct ?    29 Yes 11 No
Vignesh1988i
 
 
 
Answer
# 3
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=1;i<=10;i++)
{
if(i%2!=0)
printf("*\n");
else
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
}
getch();
}
 
Is This Answer Correct ?    15 Yes 7 No
Srinivas 9491582281
 
Answer
# 4
#include<stdio.h>
int main()
{
int n,i,j;
printf("enter the lines :");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("*\n");
for(j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");

}

compiled with GCC
 
Is This Answer Correct ?    13 Yes 7 No
Rfk
 
Answer
# 5
#include<stdio.h>
int main()
{
int n,i,j;
printf("enter the lines :");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("*\n");
for(j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");

}
 
Is This Answer Correct ?    8 Yes 5 No
Umesh Shinde
 
Answer
# 6
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j;
printf("enter the lines:");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("/n");
for(j=1;j<=2*i;j++)
printf("\n");
}
if(n%2!=0);
printf("\n");
getch();
}
 
Is This Answer Correct ?    10 Yes 8 No
Prasanna
 
Answer
# 7
void main() {
int n = 5 ; // take use input here
int i, j;
for( i =1; i<=n; i++){
printf("\n *");
for(j=0; j<=i; j++){
printf(" *");
}
}
}
 
Is This Answer Correct ?    23 Yes 22 No
Naman Patidar
 
Answer
# 8
only 1st quistion is correct and then all ar quistions are
wrong.
 
Is This Answer Correct ?    1 Yes 0 No
Kk
 
Answer
# 9
#include<stdio.h>
main()
{
int n;
printf("enter the lines");
scanf("%d",&n);
for(int i=1;i<=n/2;i++)
{
printf("*\n");
for(int j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");

}
 
Is This Answer Correct ?    4 Yes 5 No
Adhiraj Keshri
 
Answer
# 10
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j;
printf("enter the lines:");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("/n");
for(j=1;j<=2*i;j++)
printf("\n");
}
if(n%2!=0);
printf("\n");
getch();
}
 
Is This Answer Correct ?    0 Yes 1 No
Abdi
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
void main() { int i=5; printf("%d",i++ + ++i); } ME 21
what does ‘segmentation violation’ mean?   1
How the C program can be compiled? HP 10
write a program to find the frequency of a number Infosys 4
Why the below program throughs error during compilation? #include<stdio.h> #include<conio.h> enum { ZERO, ONE, TWO, }; main() { printf("%d",&TWO); getch(); }   2
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?   1
what is the difference between structure and union?   3
what is the maximum no. of bytes calloc can allocate Mphasis 4
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.   6
what is the use of fflush() function?   2
Derive the complexity expression for AVL tree?   1
m=++i&&++j(||)k++ printf("%d"i,j,k,m) ABC 1
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright © 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com