I need a C program for star background for a project.

Asked By 30 points N/A Posted on -
qa-featured

I need a C program for star background to be incorporated into my project. I am not a veteran in C programming and therefore the easier the better. Kindly include comments to enable me to learn as I carry out the incorporation process. I have tried it using some tutorials but every time I get a fatal error causing the program to stop running. Cheers!

SHARE
Best Answer by Adams Auer
Best Answer
Best Answer
Answered By 10 points N/A #132158

I need a C program for star background for a project.

qa-featured

 

Yes Jeff,

This quick tutorial link should  help you more. http://cplus.about.com/od/learningc/Learn_How_to_Write_Programs_in_C.htm

Well I wish you had specified where the background was to be.There is Graphical User Interface and the CLI(command line interface).

The code below prints a star pattern for a CLI.

 

#include <stdio.h>
 
int main()
{
   int row, c, n, temp;//declarations
 
   printf("Enter the number of rows in pyramid of stars you wish to see ");
   scanf("%d",&n);//input and store number to n
 
   temp = n;//assign n to temp
//loop
 
   for ( row = 1 ; row <= n ; row++ )
   {
      for ( c = 1 ; c < temp ; c++ )
         printf(" ");
 
      temp--;
 
      for ( c = 1 ; c <= 2*row - 1 ; c++ )
         printf("*");
 
      printf("n");
   }
 
   return 0;
}

 

 

Answered By 50 points N/A #132157

I need a C program for star background for a project.

qa-featured

Hello Jeff Mathie,

If you want to draw a star patten then you have to use to for loops. In them you have to give the condition that what you want to print. All you need is to get the knowledge of nested for loop. But if you want to print that pattern with the help of graphics then you can also BGI for that purpose. I am sending you a link from there you can get more than 10 nested for loops to be used in your program.

http://www.programmingspark.com/2012/01/pattern-programs-in-c-pattern-26.html

Login/Register to Answer

Related Questions