0% found this document useful (0 votes)
13 views

Assignment 4: Do All The Questions Using While Loop

The document contains instructions for writing several programs using while loops: 1) A program that continuously takes input from the user until 0 is entered and optionally sums the inputs. 2) A program that takes a number from the user and checks if it is a prime number. 3) A program that generates a table of intelligence quotient (IQ) scores by varying values for variables x and y in the IQ formula. 4) A program that takes the number of students in a class, calculates the sum and average. 5) A program that calculates the factorial of a positive integer or its absolute value. 6) A program that calculates a base number to the power of an exponent.

Uploaded by

SulmanIqbal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Assignment 4: Do All The Questions Using While Loop

The document contains instructions for writing several programs using while loops: 1) A program that continuously takes input from the user until 0 is entered and optionally sums the inputs. 2) A program that takes a number from the user and checks if it is a prime number. 3) A program that generates a table of intelligence quotient (IQ) scores by varying values for variables x and y in the IQ formula. 4) A program that takes the number of students in a class, calculates the sum and average. 5) A program that calculates the factorial of a positive integer or its absolute value. 6) A program that calculates a base number to the power of an exponent.

Uploaded by

SulmanIqbal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 4

Do all the questions using While Loop


Write a program which will continue taking input from user until the 0 is entered by user. Write a program which will continue taking input from user until the 0 is entered by user, also show the sum of all inputs. Write a program that will take input from user and will check either number is prime or not. An integer greater than 1 is prime if its only positive divisor is 1 or itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not. According to a study, the approximate level of intelligence of a person can be calculated using the following formula: i = 2 + ( y + 0.5x)

Write a program, which will produce a table of values of i, y and x, where y varies from 1 to 6, and for each value of y, x varies from 5.5 to 12.5 in steps of 0.5 . Implement a program that takes the number of students in a class from the user. Calculate their sum and average. Implement a program that displays the factorial of a user defined positive integer. If the integer is not positive, convert it to a positive number and then calculate factorial. Implement a program that takes the value of base and exponent from the user. The program should determine and display the result of base^exponent.

You might also like