Answer the following questions:

1) List of prime numbers Recall: a prime number is a number (greater than 1) that is only divisible by itself and 1. Write a program that prompts the user to enter a number (greater than or equal to 2). The program should then output all the primes between 1 and the number. Your program should include a function that determines if a number is prime.

2) What day of the year is it? Write a program that takes the date (in month-day-year format) and outputs the day number of the year. For instance, if the user enters 1-1-2015, the day number is 1. The program should check for a leap year. A year is a leap year if it is divisible by 4 but not divisible by 100 (e.g. 2004, 1996). However a year that is divisible by 100 is also a leap year if it is also divisible by 400 (e.g. 2000). Your program should include a function to determine the day as well as a function to check for leap years.

Extra: Reverse digits Write a program that takes an integer and outputs the reverse of an integer. For instance, if the user enters 65, the program should output 56. Your program should include a function that performs the reversal.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <vector>
using namespace std;

int readPrime() {
    int n;

    printf("please enter a prime number: ");
    scanf("%d", &n);
    return n;

vector<int> returnPrimes(int n) {
    int start_val = 2;
    vector<int> primes;

    while (start_val <= n) {
       while ((n % start_val) == 0) {
          n/= start_val;
       start_val+= 1;
    return primes;

void printPrimes(int number) {
    int vt = 0;
    vector<int> primes = returnPrimes(number);
    vector<int>::iterator v = primes.begin();

    while( v != primes.end()) {
       if (*v != vt) {
          printf("%d ", *v);
       vt = *v;
$15.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats