| | |
Hi, would you mind helping me with my homework?
![]() |
•
•
Join Date: Oct 2006
Posts: 1
Reputation:
Solved Threads: 0
Hi, I have a homework assignment that is giving me some problems. I need to make a pyramid of * with a spaces and n rows long. It should look something like this:
____*
___* *
__* * *
_* * * *
* * * * *
I have most of it but my compiler is still coming up with errors. Please help.
____*
___* *
__* * *
_* * * *
* * * * *
I have most of it but my compiler is still coming up with errors. Please help.
C Syntax (Toggle Plain Text)
# include <stdio.h> #include <stdlib.h> int main (void) { int n; for (int i=0; i<n; i++); { for (int j=0; j<n-1-i; j++); printf (" "); } { for (int k=0; k<(2*(i+1));k++) printf ("* "); } printf ("\n"); system ("PAUSE"); return 0; }
Last edited by morning_star_18; Oct 17th, 2006 at 2:14 am.
#include <stdio.h> // There should be no spaces between # and include #include <stdlib.h> int main (void) { int n = 9; // initialize n to the value you want for (int i=0; i<n; i++) // deleted the semicolon { // You print spaces until n - 1 - i for (int j=0; j<n-1-i; j++) // deleted the semicolon printf (" "); // After printing spaces print * until n for (int k=n-1-i; k<n;k++) printf ("* "); printf ("\n"); } system ("PAUSE"); // use cin.get() or something return 0; }
バルサミコ酢やっぱいらへんで
![]() |
Similar Threads
- Need Help on other homework (Computer Science)
- Assistance with change program (C++)
- Average of prime number between 1 & 100 (C#)
- Help!!!!!! (C++)
- I Need Help!! (Java)
- Beginner Networking (Networking Hardware Configuration)
- Translate an algorithm to C program (C)
Other Threads in the C Forum
- Previous Thread: round off number
- Next Thread: Console Programming
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard strchr string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h






