Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   star pttern genration program in c laguage using while loop (http://www.go4expert.com/forums/star-pttern-genration-program-c-laguage-t19039/)

mrunalini 15Aug2009 06:52

star pttern genration program in c laguage using while loop
 
/*write a program to genrate star pattern as shown below using while loop*/

*
**
***
****
*****

SaswatPadhi 15Aug2009 06:55

Re: star pttern genration program in c laguage using while loop
 
It's not a very hard task to do.
Don't ask us for answers to you homework.

Show us your progress (your code till now), and we would be happy to help.

mayjune 15Aug2009 19:11

Re: star pttern genration program in c laguage using while loop
 
If you are asking for this code, you are lazy to try it out...
Hint - Use the value of variable i (if i = 0 to 5) to print "*" that many times...
Trust me we can tell you the code, you'll pass your homework, but wont get programming!!
Do it yourself..

mrunalini 15Aug2009 20:27

Re: star pttern genration program in c laguage using while loop
 
:pleased:
Quote:

Originally Posted by mayjune (Post 55246)
If you are asking for this code, you are lazy to try it out...
Hint - Use the value of variable i (if i = 0 to 5) to print "*" that many times...
Trust me we can tell you the code, you'll pass your homework, but wont get programming!!
Do it yourself..


mayjune 15Aug2009 21:56

Re: star pttern genration program in c laguage using while loop
 
try it, paste it if you get it, if you don't, post what you got till then...
these patten generating will get you how to use your code repeatedly....there are many levels to this * generation...so doing it will clear your programming concept...
All the best...

mrunalini 16Aug2009 01:38

Re: star pttern genration program in c laguage using while loop
 
Programme:
Code:

#include<stdio.h>
#include<conio.h>
main( )                                                                       
{  int i,j;                                                                 
  clrscr( );                                                                 
  i=1;                                                                     
  while(i<=5)                                                               
  {                                                                         
      printf("  ");                                                         
      j=1;                                                                   
      while(j<=i)                                                           
      {                                                                     
        printf(" * ");                                                     
        j++;                                                               
      }                                                                     
      printf("\n");                                                         
      i++;                                                                 
  }                                                                         
    getch( );                                                                 
}

O/P:
Code:

    *
    *  *
    *  *  *
    *  *  *  *
    *  *  *  *  *


mrunalini 16Aug2009 01:43

Re: star pttern genration program in c laguage using while loop
 
thank u for rply ,
i m beginner in c lang, but not at all lazy ok.














Quote:

Originally Posted by mrunalini (Post 55252)
:pleased:

Quote:

Originally Posted by mayjune (Post 55257)
try it, paste it if you get it, if you don't, post what you got till then...
these patten generating will get you how to use your code repeatedly....there are many levels to this * generation...so doing it will clear your programming concept...
All the best...


mayjune 16Aug2009 11:47

Re: star pttern genration program in c laguage using while loop
 
:) Good...
I recommend using for loop instead of while, as you can initialize, condition and increment/decrement in the same line, moreover you can skip any or all part of it (i.e. initialize, condtion and inc/decrement)
thus for a programmer its more visible and clear to understand....
Try doing this pattern...
*
**
***
**
*

If you want i can give you lot of patterns to practice, which will help you improve your skills...
Have fun...

xpi0t0s 16Aug2009 13:43

Re: star pttern genration program in c laguage using while loop
 
Quote:

Originally Posted by mrunalini (Post 55262)
thank u for rply ,
i m beginner in c lang, but not at all lazy ok.

Don't take it personally. We get a lot around here who are lazy, they think we're expert enough to do their homework for them but not expert enough to notice that's what we're doing. Your original message stated "write a program to genrate star pattern as shown below using while loop", which did rather take the form of a lazy person's post. Well done for solving the problem on your own!

Next time, to avoid the same problem, it would be a good idea to post some code along with an explanation of where you're stuck. Say what the program isn't doing that you expect, what input you gave, and what the program should do, then we stand a good chance of solving it simply by looking at the code.

mayjune 16Aug2009 18:37

Re: star pttern genration program in c laguage using while loop
 
well said xp...


All times are GMT +5.5. The time now is 01:35.