Fruit Stand Pass by Value Only - Arup Guha Example of using...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// Arup Guha // 2/12/04 // Example of using several functions to print several types of designs. #include <stdio.h> void printChars(char ch, int numtimes); void printTriangle(char ch, int n); void printOtherTri(char ch, int n); void printBackTri(char ch, int n); void printSquare(char ch, int n); void printPyramid(char ch, int n); int menu(); int main() { char dummy, ch; int ans, n; ans = menu(); // Continue processing choices till the user quits. while (ans != 6) { // Ask for the character and size for the design. printf("What character would you like your design made from?\n"); scanf("%c%c", &dummy, &ch); printf("What size do you want your design to be?\n"); scanf("%d", &n); // Carry out the appropriate choice. if (ans == 1) printTriangle(ch, n); if (ans == 2) printOtherTri(ch, n); if (ans == 3) printBackTri(ch, n); if (ans == 4) printPyramid(ch, n); if (ans == 5) printSquare(ch, n); // Get the new choice. ans = menu(); } return 0; } // Prints out a menu and returns the user's menu choice. int menu() { int choice=0; printf("Which choice would you like?\n"); printf("1. Print a normal right triangle, left justified.\n"); printf("2. Print a right triangle, right justified.\n"); printf("3. Print a right triangle, backwards.\n"); printf("4. Print a pyramid.\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
printf("5. Print a square.\n"); printf("6. Quit.\n"); // Loop until a valid answer is entered. while (1) {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Fruit Stand Pass by Value Only - Arup Guha Example of using...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online