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

What is p in text message?

0 Answers  


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

0 Answers  


Given an unsigned integer, find if the number is power of 2?

5 Answers  


write a programme to enter some number and find which number is maximum and which number is minimum from enterd numbers.

3 Answers  


What is s or c?

0 Answers  






int i=10; printf("%d %d %d", i, i=20, i);

0 Answers  


which operator having lowest precedence?? a.)+ b.)++ c.)= d.)%

4 Answers  


I have seen function declarations that look like this

0 Answers  


What's the difference between a linked list and an array?

14 Answers  


what is disadvantage of pointer in C

13 Answers   Tech Mahindra,


what are enumerations in C

0 Answers   TCS,


What is the modulus operator?

0 Answers  


Categories