Creates a string concat primes of given length

Assignment Help C/C++ Programming
Reference no: EM131373871

Write a C++ program which:

1. takes an integer n ≥ 0 from stdin provided by the user.

2. creates a string concat primes of length 1000 from the first k prime numbers by concatenating them as strings. (You have to decide on the value of k).

3. The program has to compile and work perfectly in visual studio or xcode (mac)

4. prints the first 5 characters of concat primes starting at index n.

For example, the first k prime numbers are 2, 3, 5, 7, 11, 13, 17.... Thus, concat primes = "2357111317...". If the user provides n = 3, the program should print 71113.

A sample of expected output for various values of n is given below:
n Output
0 = 23571
3 = 71113
6 = 13171
10 = 19232
120 = 92332
998 = 91

Using this format
#include<iostream>
#include<string>

std::string get_concatenated_primes()
{
return "2357111317";
}

std::string get_slice_of_5(const std::string & primes, const int index)
{
return "23571";
}

int main()
{
int n;

while(std::cin >> n)
{
std::string concat_primes = get_concatenated_primes();
std::cout << get_slice_of_5(concat_primes, n) << std::endl;
}

return 0;
}

Reference no: EM131373871

Questions Cloud

Environments of service and manufacturing organizations : On what dimensions of external dependence do the environments of service and manufacturing organizations differ? Does this have implications for how these two types of organizations might manage their environmental interactions?
Who developed the leed rating system : Why is it important to meet the building standards during new construction rather than waiting until some later time to incorporate them?
Which of the following is an intangible asset : Which of the following is an intangible asset - If an owner invests her laptop computer and printer in the business, there is an increase
Refinement of a random process : What are your thoughts concerning the probability that programmed development resulted from refinement of a random process?
Creates a string concat primes of given length : creates a string concat primes of length 1000 from the first k prime numbers by concatenating them as strings. (You have to decide on the value of k).
Why is the role of the boundary spanner so important : 2. Why is the role of the boundary spanner so important? so difficult? How could an organization prepare one of its employees for this role?
Phenotype seen in the mutant fly : The convention for naming genes is to name them after the phenotype seen in the mutant fly. Based on this convention, which of the following is the best choice for naming the gene involved in fly eye color that was identified in this study of flie..
Respond to the presidents memorandum : Assume that you are the vice president, and respond to the president's memorandum. Consider as many aspects of the environment as you can apply to this situation.
Develop a mandatory green building standards code : What makes a building sustainable? From a financial perspective, should owners of a sustainably managed building expect a higher return on investment?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd