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 (2253)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
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
 
wat is the output #define VOLEDEMORT _who_must_not_be_named int main() { printf("VOLEDEMORT"); }   2
program for swapping two strings by using pointers in c language   1
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack   6
a simple program in c language IBM 3
What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value Accenture 3
Average of a couple 10 years ago was 25. The average remains same after having a child and twins after 3 years. What is the present age of the first child IBM 10
#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1); } Tell me the output? Ramco 6
Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5   3
what is the use of a array in c   6
what is inline function?   2
main() { int a = 65; printf(%d %o %x,a,a,a); } Output 65 101 41 Please explain me.How it is coming like that? Excel 3
How to add two numbers without using arithmetic operators? Sapient 18
 
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