Write a program that prompts the user for an integer


(1) Write a program that prompts the user for an integer and then prints out all prime numbers up to that integer. For example, when the user enters 20, the program should print: 2 3 5 7 11 13 17 19.

Recall that a number is a prime number if it is not divisible by any number except 1 and itself.


(2) Write a function which calculates leap years. The function prototype is as follows:

bool leap_year(int year);

Write the function body which returns true if the year is a leap year and false if the year is not a leap year.

NOTE: A leap year is defined as any year divisible by 4 with the following exception:

Years that are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400

Also note that any year prior to 1582 is not a leap year.

Your submission should include a fully functional program including a main program that tests your leap year function.


(3) In three paragraphs answer the following questions:
• How many constructors can a class have?
• Can you have a class with no constructors?
• If a class has more than one constructor, which of them gets called?

Required minimum 1 page

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a program that prompts the user for an integer
Reference No:- TGS081705

Expected delivery within 24 Hours