COP 3223 Introduction to C Assignment 5.RAR

COP 3223 Introduction to C Assignment 5

This assignment is worth a maximum of 100 points Objectives: The purpose of this assignment, is for students to demonstrate knowledge of • the basic template of a simple C program • correct syntax for nested while and for loops • semantics of nested while and for loops in C • how to declare appropriate variable types to store program data • how to use simple C syntax and semantics to create a program that compiles and runs correctly  use of comments to annotate code Problem: Write a program that asks the user to enter a positive odd integer, n. If the integer is 0 or less, print out a message saying the integer is too small and ask the user to re-enter the integer. If the integer is even, print out a message saying that the integer must be odd and ask the user to re-enter the integer. Your program should keep prompting the user to enter valid input until they do. When the user enters a valid input, print out a diamond with n rows. For example, when n =5 your program should print the diamond below. * *** ***** *** * Notice that not only must the number of stars on each row be accurate, but so must the number of spaces.
Submission of Assignment Your assignment should be submitted via Webcourses by the deadline. No assignments will be accepted via email. Your submission should include a single .c file called diamond.c . Remember that your program will be graded using DevC++ , so be sure that your submitted code runs correctly in this IDE. If you do not have DevC++ on your personal machine, you may use a computer in any lab to test your code. Restrictions: The code constructs used in the assignment solution should include only material covered in class up to day of submission with NO exceptions. Your code should only print one star or one space at a time. This means that you cannot have a printf statement printing ****** for example
Sample run2:
Powered by