Asked By
jeff mathie
30 points
N/A
Posted on - 04/05/2013
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!
I need a C program for star background for a project.
Â
Yes Jeff,
This quick tutorial link should  help you more. https://www.thoughtco.com/c-and-c-plus-programming-4133470
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;
}
Â
Â
I need a C program for star background for a project.
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