Question: In C Language: Problem 1 (10 points): Write a program with a while loop to print 1 to N in square brackets. N is an
In C Language:
Problem 1 (10 points): Write a program with a while loop to print 1 to N in square brackets. N is an integer input from the user. (i) (ii) Write the same program using a for-loop Write the same program that will display only the even numbers and odd numbers from 1 to N. Example of Output (Expected output as well): Enter the value of N: 9 Numbers : ["1"] ["2"] ["3"] ["4"] ["5"] ["6"] Even nunbers: "2"1 "4"1 "6"1 "8"1 Odd numbers : ["1"] [..3..] ["5"] [..?..] ["9' ["7" ] [.'8"] ["9"] Problem 2 (10 points): Write a program that will repeatedly prompt the user to type a number until the user types a non- negative number then square it. Example of Output (Expected output as well): Enter a positive integer: -9 That's a negative number! Please enter a positive number: -8 That's a negative number Please enter a positive nunber: 6 Square of 636 Problem 1 (10 points): Write a program with a while loop to print 1 to N in square brackets. N is an integer input from the user. (i) (ii) Write the same program using a for-loop Write the same program that will display only the even numbers and odd numbers from 1 to N. Example of Output (Expected output as well): Enter the value of N: 9 Numbers : ["1"] ["2"] ["3"] ["4"] ["5"] ["6"] Even nunbers: "2"1 "4"1 "6"1 "8"1 Odd numbers : ["1"] [..3..] ["5"] [..?..] ["9' ["7" ] [.'8"] ["9"] Problem 2 (10 points): Write a program that will repeatedly prompt the user to type a number until the user types a non- negative number then square it. Example of Output (Expected output as well): Enter a positive integer: -9 That's a negative number! Please enter a positive number: -8 That's a negative number Please enter a positive nunber: 6 Square of 636
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
