Question

In: Computer Science

Make 2 hard programming (1 about pattern and 1 about anything) problem in c++ that can...

Make 2 hard programming (1 about pattern and 1 about anything) problem in c++ that can be solved in around 30 minute

give the problem + the answer please

i need for learning c++

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main(){

int n, i, j, space = 1;

cout<<"Enter size: ";

cin>>n;

space = n - 1;

// prints the upper part

for (j = 1; j <= n; j++)

{

for (i = 1; i <= space; i++)

{

cout<<"*";

}

space--;

for (i = 1; i <= 2 * j - 1; i++)

{

  if(i==1 || i==2*j-i)

cout<<"*";

}

cout<<endl;

}

space = 1;

// prints the lower part

for (j = 1; j <= n - 1; j++)

{

  // prints the spaces

for (i = 1; i <= space; i++)

{

cout<<"*";

}

space++;

// prints the stars

for (i = 1; i <= 2 * (n - j) - 1; i++)

{

  if(i==1 || i==(2*n-j)-1)

cout<<"*";

}

cout<<endl;

}

}

Answer 2:

#include <iostream>

using namespace std;

int main(){

int start,end;

cout<<"Enter start and end ranges to print Prime numbers : ";

cin>>start;

cin>>end;

//iterating in range

for(int i=start;i<end;i++){

int count=0;

//checking for prime

for(int j=1;j<=i;j++){

//checking for factors

if(i%j==0){

count++;

}

}

//if factors are 2 than it is prime

if(count==2)

cout<<i<<" ";

}

}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Using C programming make one for loop Description For this problem you will be figuring out...
Using C programming make one for loop Description For this problem you will be figuring out if it is more beneficial to pay off your loans first before investing or if you should only make the minimum payments and invest the rest. Some things to pay attention to Interest rates given are annual interests rates but we will be assuming that interest is compounded monthly so the real rates to use will be 1/12 of what we are given We...
Chapter 2, Problem 4E in An Introduction to Programming with C++ All of the employees at...
Chapter 2, Problem 4E in An Introduction to Programming with C++ All of the employees at Merks Sales are paid based on an annual salary rather than an hourly wage. However, some employees are paid weekly while others are paid every other week (biweekly). Weekly employees receive 52 paychecks; biweekly employees receive 26 paychecks. The payroll manager wants a program that displays two amounts: an employee’s weekly gross pay and his or her biweekly gross pay. Complete an IPO chart...
Make a simple game using C++ which implements all about Object Oriented Programming (Please make an...
Make a simple game using C++ which implements all about Object Oriented Programming (Please make an explanation which of each part in it)
Having learned the hard core MapReduce Programming techniques, what is your opinion about MapReduce programming for...
Having learned the hard core MapReduce Programming techniques, what is your opinion about MapReduce programming for solving big data business problems.   Here are the options for your rating- 1)YUCK, 2)MEH, 3)GOOD, 4)AWESOME. Please choose one of the above rating with an explanation. Please give me your honest opinion about Mapreduce programming only! (not other topics like HDFS architecture, or HDFS programming of Hadoop or YARN in general).
Problem: Make linkedList.h and linkList.c in Programming C language Project description This project will require students...
Problem: Make linkedList.h and linkList.c in Programming C language Project description This project will require students to generate a linked list of playing card based on data read from a file and to write out the end result to a file. linkedList.h Create a header file name linkedList Include the following C header files: stdio.h stdlib.h string.h Create the following macros: TRUE 1 FACES 13 SUITS 4 Add the following function prototypes: addCard displayCards readDataFile writeDataFile Add a typedef struct...
Problem 1: For the following linear programming problem: ???????? ? = 40?1 + 50?2 Subject to...
Problem 1: For the following linear programming problem: ???????? ? = 40?1 + 50?2 Subject to constraints: 3?1 − 6?2 ≥ 30 ?1 – 15 ≤ 3?2 2 ?1 + 3 ?2 = 24 ?1, ?2 ≥ 0 1- Find the optimal solution using graphical solution corner points method or iso profit line method. Please, show the values for state variable, decisions variables, and slack and surplus variables 2- Determine the value for basic solution and non-basic solution, binding constraints...
C++ Programming: Programming Design and Data Structures Chapter 13 Ex 2 Redo Programming Exercise 1 by...
C++ Programming: Programming Design and Data Structures Chapter 13 Ex 2 Redo Programming Exercise 1 by overloading the operators as nonmembers of the class rectangleType. The header and implementation file from Exercise 1 have been provided. Write a test program that tests various operations on the class rectangleType. I need a main.cpp file Given: **************rectangleType.cpp******************** #include <iostream> #include <cassert> #include "rectangleType.h" using namespace std; void rectangleType::setDimension(double l, double w) { if (l >= 0) length = l; else length =...
1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages  ...
1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages   2.String and StringBuffer (C#, Java) with examples.
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a) No fraction allowed Max Weight W= 9 item 1: profit $20, weight 2, prof/weight=$10 item 2: profit $30, weight 5, prof/weight=$6 item 3: profit $35, weight 7, prof/weight=$5 item 4: profit $12, weight 3, prof/weight=$4 item 5: profit $3, weight 1, prof/weight=$3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT