Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Write a program to print star using * ? (http://www.velocityreviews.com/forums/t953779-write-a-program-to-print-star-using.html)

Nikhil Joshi 10-23-2012 03:52 PM

Write a program to print star using * ?
 
guys help me in making thi program?

Joe Pfeiffer 10-23-2012 03:56 PM

Re: Write a program to print star using * ?
 
Nikhil Joshi <nitin.nitinperderusted.rastogi@gmail.com> 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 '*'.

Nikhil Joshi 10-23-2012 04:03 PM

Re: Write a program to print star using * ?
 
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?

BartC 10-23-2012 04:25 PM

Re: Write a program to print star using * ?
 


"Nikhil Joshi" <nitin.nitinperderusted.rastogi@gmail.com> wrote in message
news:9291e324-bdc8-4153-b40e-4c53fc4bcec3@googlegroups.com...
> 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


James Kuyper 10-23-2012 04:35 PM

Re: Write a program to print star using * ?
 
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.


Joe Pfeiffer 10-23-2012 04:45 PM

Re: Write a program to print star using * ?
 
Newsgroups: comp.lang.c
Subject: Re: Write a program to print star using * ?
From: Joe Pfeiffer <pfeiffer@cs.nmsu.edu>
--text follows this line--
Nikhil Joshi <nitin.nitinperderusted.rastogi@gmail.com> 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).

Joe Pfeiffer 10-24-2012 01:45 AM

Re: Write a program to print star using * ?
 
pete <pfiland@mindspring.com> 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!

Lew Pitcher 10-24-2012 01:59 AM

Re: Write a program to print star using * ?
 
On Tuesday 23 October 2012 11:52, in comp.lang.c,
nitin.nitinperderusted.rastogi@gmail.com 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"

Lew Pitcher 10-26-2012 01:52 PM

Re: Write a program to print star using * ?
 
On Thursday 25 October 2012 23:23, in comp.lang.c, pfiland@mindspring.com
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"

Nick Keighley 10-27-2012 01:05 PM

Re: Write a program to print star using * ?
 
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



All times are GMT. The time now is 04:37 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.