how can i get this by using for loop?
*
**
*
****
*
******

Answers were Sorted based on User's Feedback



how can i get this by using for loop? * ** * **** * ******..

Answer / suman_kotte

int i,j;
for(i=1;i<=3;i++)
{
print("*");
print("\n");
for(j=1;j<=i*2;j++)
print("*");
print("\n");
}

Is This Answer Correct ?    14 Yes 1 No

how can i get this by using for loop? * ** * **** * ******..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int m;
clrscr();
printf("enter the lines :");
scanf("%d",&m);
for(int i=1;i<=m;i+=2)
{
for(int j=-2;j<=i;j+=2)
printf("*");
printf("*\n*");
}
getch();
}


thank u

Is This Answer Correct ?    1 Yes 0 No

how can i get this by using for loop? * ** * **** * ******..

Answer / vignesh1988i

sorry folks, a small mistake in above program , the below is the correct one's...........


#include<stdio.h>
#include<conio.h>
void main()
{
int m;
clrscr();
printf("enter the lines :");
scanf("%d",&m);
for(int i=1;i<=m;i+=2)
{
printf("*");
for(int j=-2;j<=i;j+=2)
printf("*");
printf("*\n");
}
getch();
}


thank u

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Explain c preprocessor?

0 Answers  


Explain what is a const pointer?

0 Answers  


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

0 Answers   College School Exams Tests,


What does 4d mean in c?

0 Answers  


What is Memory leakage ?

2 Answers   HCL,


what is the output? #define fun(a,b,t) (g ##t=(a),(a)=(b),(b)=g##t) float gfloat; main() { float a=1.12,b=3.14; fun (a,b,float); printf("na=%4.2f,b=%4.2f",a,b); } A)Error in Defining Macro B)a=1.12,b=3.14 C)a=3.14,b=1.12 D)None of the Above

3 Answers   Accenture, Infosys, Wipro,


What is C++

4 Answers  


What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }

4 Answers   ADITI,


Explain how do you determine the length of a string value that was stored in a variable?

0 Answers  


Write a program for finding factorial of a number.

0 Answers   Tech Mahindra,


What are qualifiers?

0 Answers  


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

3 Answers   ME, pspl,


Categories