Beginners - April 2019 (Page 2)

std::swap()
 
Hello, I've read that the std::swap() function is valid for any data type, as long as they can be copied. Does this also hold for user-defined types?
[5 replies] Last: @kyrresc: Read about name lookup: https://en.cppreference.com/w/cpp/la... (by keskiverto)
the char data type error
 
Hello Everyone!! when I type (y or Y) or (n or N) it correspondingly outputs the according to code. Also outputs "please enter correctly.." when I type say b...
[2 replies] Last: Thank You, I got that... (by pratyushmisra)
can someone explain how the vlaue is 6?
 
as the tittle suggests, can someone explain to me how the value here is 6 int Operation1(int a, int b) {return (a / b); } int Operation2(int b, int ...
[3 replies] Last: can someone explain to me how Can you explain to us how you did work... (by keskiverto)
result not correct
 
It give output as 2 though I declared y as float.I want it to give ans 2.5 #include <iostream> #include <cmath> using namespace std; int main() { ...
[7 replies] Last: Mike's code makes it hard to see the decimal point (he was doing that... (by MikeStgt)
Recursive Functions: Getting the Sum of Even or Odd Integers in Given Range
 
I'm writing a C++ program that asks the user to enter a single number from 1 to 50 and a choice of "even" or "odd". Using a recursive function, it will then out...
[3 replies] Last: #include <iostream> #include <string> using namespace std; int main(... (by lastchance)
by Eto
Find n prime numbers
 
#include <iostream> using namespace std; void getPrime(int); int main() { int n; cout << "Enter a prime number and we'll tell you that number of p...
[3 replies] Last: See https://github.com/kimwalisch/primesieve#primesieve (by MikeStgt)
Sorting by Last Name
 
So I have a text file with students names. I made a struct with first names, last names, and grade. I'm supposed to sort the names by last name. The way I sorte...
[4 replies] Last: > I also changed the loop variables and it outputed the names correctl... (by salem c)
Calculating an Average
 
I have an assignment where I have 20 students with different test scores. The test score is set as a structure. I'm having trouble setting up the function to fi...
[4 replies] Last: I saw in the diagnostics my test scores were were incorrect. I fixed i... (by simulationspecimen)
two dimensional array
 
Write a C++ program that uses a two-dimensional array to display a table of probabilities for a pair of rolling dice. Your custom assigned range of values of...
[3 replies] Last: int dice1 = rand() % 9 + 4; This gives a range of 4 to 12. It is a... (by George P)
Help with vectors (modifying, adding, deleting)
 
I've been having a really hard time with this assignment. The description of the assignment is a bit long, but basically we were given a code and asked to modi...
[2 replies] Last: There are several different ways to create and initialize the contents... (by George P)
How do you verify if a password contains a digit?
 
Hi, right now I'm working on a final project for my comp sci class. Part of the project involves prompting the user to create their own password. I wanted ...
[3 replies] Last: Works perfectly. Thank you guys for all your help. Much appreciated. (by kdrewes)
Code Clean Up Help
 
Good Afternoon, I am trying to clean up my code and what I would like to do is find a way to turn the following bit of code into a function. Everything works ...
[2 replies] Last: Create a reserveSeat() function that takes the start and end rows to d... (by dhayden)
by Joo
Problem with copying a region from two dimensional array to another two dimensional array
 
I have a problem with my program. I want to copy a certain region of size SS around a pixel of index i,j from a source 2-D array named as (padded) of a bigger s...
[4 replies] Last: I've made a testing environment for Joo's function. There I got no seg... (by nuderobmonkey)
Scoped enum as input to function
 
This should be easy but.. I have the following scoped enum defined enum class Suit{clubs,diamonds,hearts,spades}; how do I pass it to a function and d...
[1 reply] : std::string to_string( Suit s ) { switch(s) { case Suit... (by JLBorges)
Errors with classes
 
I am using CodeBlocks to learn C++. The problem I'm having is I created a class. Like 2 other files, a .cpp and a .h file. I'm getting errors and I don't know w...
[3 replies] Last: http://wiki.codeblocks.org/index.php/Creating_a_new_project (by Repeater)
User Defined Functions and Arrays
 
Good Morning, I realized on my last question I phrased it wrong, I would like to have a user defined function that I pass an array to for editing. Is this pos...
[3 replies] Last: yes. its already reference, so change it in the function and it will ... (by jonnin)
Adding two polynomials
 
Hye! I am trying to add two polynomials whose exponents and coefficients are entered by user himself.Later I have to multiply and subtract too! But right now it...
[1 reply] : Before delving into your code, please note you’re shadowing your cla... (by Enoizat)
Arrays and changing an int into a symbol
 
Good Morning, I have two questions, the first is is it possible to have a user defined array reference an array for changing its data. The second one is I n...
[2 replies] Last: Thank you very much, that helped alot! (by thylath)
by Guil
problem with truncate
 
I would like to truncate a file and to remove the end of the file in this scoop i use truncate int main() { ///// creation d'un fichier random avec de...
[1 reply] : Hello Guil, PLEASE ALWAYS USE CODE TAGS (the <> formatting button),... (by Handy Andy)
Adding an image to a microsoft word file
 
I am working on a small program that produces a story and prints it into a Microsoft word file. I'm wondering is there any way to input an image into this word ...
[1 reply] : Well if you're talking about docx files, they're just XML files in a Z... (by salem c)
April 2019 Pages: 1234... 24
  Archived months: [mar2019] [may2019]

This is an archived page. To post a new message, go to the current page.