Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Write a program to print star using * ?

Reply
Thread Tools

Write a program to print star using * ?

 
 
Nikhil Joshi
Guest
Posts: n/a
 
      10-23-2012
guys help me in making thi program?
 
Reply With Quote
 
 
 
 
Joe Pfeiffer
Guest
Posts: n/a
 
      10-23-2012
Nikhil Joshi <> writes:

> guys help me in making thi program?


We can better help if you can show us what your initial try looks like,
and tell us what it's doing instead of printing a '*'.
 
Reply With Quote
 
 
 
 
Nikhil Joshi
Guest
Posts: n/a
 
      10-23-2012
On Tuesday, October 23, 2012 9:22:33 PM UTC+5:30, Nikhil Joshi wrote:
> guys help me in making thi program?


main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
{
printf("*");
printf("\n");
}
}
getch();
}



this is basic structure printing star..but dont know how make a program for star?
 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      10-23-2012


"Nikhil Joshi" <> wrote in message
news:9291e324-bdc8-4153-b40e-...
> guys help me in making thi program?


What shape of star? And how big? Solid or outline? Text output or image?
Colour, greyscale or mono?

Give an example just using text (assume we have a fixed pitch display). Then
it'll be easier to see how to achieve it programmatically.

--
Bartc

 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      10-23-2012
On 10/23/2012 12:03 PM, Nikhil Joshi wrote:
> On Tuesday, October 23, 2012 9:22:33 PM UTC+5:30, Nikhil Joshi wrote:
>> guys help me in making thi program?

>
> main()
> {
> int i,j;
> for(i=0;i<5;i++)
> {
> for(j=i;j<5;j++)
> {


You should #include <stdio.h> at the top of your program, before using
the following functions.

> printf("*");
> printf("\n");
> }
> }
> getch();


That is not a C standard library function. You should avoid using such
functions unless necessary. If it is necessary, your program will not be
portable to systems where getch() is not provided, or has different
behavior than you expect it to have, so you need to know which systems
your program is intended to run on, and you should also let us know.

> }
>
>
>
> this is basic structure printing star..but dont know how make a program for star?


You need to tell us more precisely what it is you want your program to
do. Except for the two issues I've raised, the behavior of your program
is quite clear, but it's not clear how it fails to meet your needs.

 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a
 
      10-23-2012
Newsgroups: comp.lang.c
Subject: Re: Write a program to print star using * ?
From: Joe Pfeiffer <>
--text follows this line--
Nikhil Joshi <> writes:

> On Tuesday, October 23, 2012 9:22:33 PM UTC+5:30, Nikhil Joshi wrote:
>> guys help me in making thi program?

>
> main()
> {
> int i,j;
> for(i=0;i<5;i++)
> {
> for(j=i;j<5;j++)
> {
> printf("*");
> printf("\n");
> }
> }
> getch();
> }
>
>
>
> this is basic structure printing star..but dont know how make a program for star?


First, get in the habit of indenting your code for readability and
declaring functions correctly:

int main(void)
{
int i,j;
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
{
printf("*");
printf("\n");
}
}
getch();
}

OK, your program prints a column of 25 *'s. Please try to say more
completely what it's supposed to do instead (and what you've tried to
do to get it to do it).
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a
 
      10-24-2012
pete <> writes:

> Nikhil Joshi wrote:
>>
>> On Tuesday, October 23, 2012 9:22:33 PM UTC+5:30, Nikhil Joshi wrote:
>> > guys help me in making thi program?

>>
>> main()
>> {
>> int i,j;
>> for(i=0;i<5;i++)
>> {
>> for(j=i;j<5;j++)
>> {
>> printf("*");
>> printf("\n");
>> }
>> }
>> getch();
>> }
>>
>> this is basic structure printing star..
>> but dont know how make a program for star?

>
> /* BEGIN new.c */
>
> #include <stdio.h>
>
> int
> main(void)
> {
> puts(" * ");
> puts(" ");
> puts(" ");
> puts(" ");
> puts("* * * *");
> puts(" ");
> puts(" ");
> puts(" ");
> puts(" * * ");
> puts(" ");
> puts(" ");
> puts(" * ");
> puts(" ");
> puts(" ");
> puts(" * * ");
> return 0;
> }
>
> /* END new.c */


Hey -- don't just do his homework for him!
 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a
 
      10-24-2012
On Tuesday 23 October 2012 11:52, in comp.lang.c,
wrote:

> guys help me in making thi program?



Sure


This is a star
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
*
***
*****
***************
*************
***********
*************
***************
*****
***
*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It is made up of two triangles
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
*
***
*****
*******
*********
***********
*************
***************



^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv



***************
*************
***********
*********
*******
*****
***
*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
superimposed over each other.

The contents of each row of each triangle has a mathemetical relationship to
the order of the row; both the number of stars, and the number of spaces to
indent to the first star can be computed knowing only the row number.

Now, all you have to do is formulate a loop that builds the star in rows;
computing the number of stars and the indent for each row of each triangle,
and superimposing one triangle over the other.

It's just a simple matter of programming.

--
Lew Pitcher
"In Skills, We Trust"
 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a
 
      10-26-2012
On Thursday 25 October 2012 23:23, in comp.lang.c,
wrote:
[snip]
> And now,
> because it's almost the same program,
> something that resembles a Koch snowflake:
>
> /* BEGIN snowflake.c output */

[snip]

Double Plus One good

--
Lew Pitcher
"In Skills, We Trust"
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      10-27-2012
On Oct 23, 4:52*pm, Nikhil Joshi
<nitin.nitinperderusted.rast...@gmail.com> wrote:

subject: write a program to print a star

> guys help me in making thi program?


#include <stdio.h>
#include "universe.h"

// not standard
#pragma use_star_printer

int main (void)
{
printf ("%S", STAR_POLARIS);
return 0;
}

do not run this program near (<100AU) other stellar bodies as it may
cause Undefined Behaviour

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Star Wars Q: How severe are the bars on widescreen Star Wars DVD set? TNEXTWAVE DVD Video 22 10-01-2004 10:44 PM
DVD Verdict reviews: THE STAR WARS TRILOGY, STAR TREK: THE ORIGINAL SERIES, SEASON ONE, and more! DVD Verdict DVD Video 0 09-27-2004 09:08 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM
Re: Sound problems on DVDs (was Re: Star Wars digression was Re: The Myths of Gaming) (was: Star Wars digression was Re: The Myths of Gaming) Terry Austin DVD Video 0 12-02-2003 03:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57