Beginners - April 2020 (Page 19)

Write a function prototype and a function definition
 
Please help in my assignment in C++. We have not been taught yet and I am running out of time Question: Write a function prototype and a function definition ...
[2 replies] Last: https://www.learncpp.com/cpp-tutorial/forward-declarations/ (by George P)
by Majeek
Code running slow on certain function
 
/* THIS IS MY PROJECT: Write a program that creates a linked list of bunny objects. Each bunny object must have ...
[3 replies] Last: Note: The max amount of bunnys a colony can have is 1000, but that che... (by jonnin)
by Dee5
Wrong output
 
Sorry my program keeps on giving wrong output someone please if know anything wrong. Example I put 2 1 3 2 5 The first line is number of inputs The fo...
[4 replies] Last: Oh thanks it worked I declared ans like this int ans=0; ... (by Dee5)
Filling an array with integers from a file
 
Hey, this is my first time posting on this site. I got assigned something for my lab where we are given a bunch of numbers and were told to load them into an ar...
[3 replies] Last: Glancing at it, it looks like you're reading them in, but the order of... (by fiji885)
My toString() not working
 
#include <iostream> #include "Conference.h" #include "Event.h" #include "Person.h" #include "Lesson.h" #include <string> #include <vector> using nam...
[2 replies] Last: Person *personptr = new Person(fn, ln, pn); return personptr; ... (by phazed99)
how to swap values in a function
 
I am trying to write a function that will take three parameters: the first two are integers that will be swapped, and the third will be a multiplier value. I am...
[1 reply] : C++ isn't python. void swapAndMult (int& a, int& b, int multiplier) ... (by lastchance)
Do-while loop error
 
Im writing a do-while loop for my calculator program, but it needs to quit right of the bat if the user enters Q. When i type Q why does it proceed to still ask...
[15 replies] Last: Also thank you very much for the help, you saved me from headache this... (by ChrisValvo)
Efficient Algorithm for subarray product
 
Can someone please Suggest an efficient algorithm O(nlogn) or O(n) for finding number of continuos subarray with product of elements divisible by 2 but not divi...
[5 replies] Last: Divide by 2 until the number is odd and that will tell you the power o... (by helios)
trying to define a friend function which add two matrix
 
Hello there! i am a beginner user of c++ i am trying to write a code which get two different matrix and add them together i dont know why the output of the frie...
[12 replies] Last: U is a reference to P3. That was created and scoped in main, so it i... (by jonnin)
Discount C++ program using a switch statement
 
Hello there, so basically im trying to do a small program that let the user enter a value then if the value equal or greater than x make discount something like...
[7 replies] Last: #include <iostream> using namespace std; int main() { int trigger... (by lastchance)
Interest While Loops
 
I can't really pinpoint what's wrong here. This question asks how many years it would take for the investment to double with a given contribution, but with no ...
[3 replies] Last: It works, but there's a lot of duplicated code there. That needlessly... (by MikeyBoy)
by cirro
am having tough time to get the correct answere
 
i cant get this to giv right answer on the second else if .when i age is less than 18 and cash is more than 100 it is saying enter the bar instead of saying u c...
[7 replies] Last: thanks it worked out i appreciate ur help (by cirro)
Using a while loop to check if a char exists in a string
 
How can I use a while loop to check if a specific char exists in a string? for example if my string was "Hello World", and I wanted to check if the char o wa...
[2 replies] Last: Hello printfsalad, size_t index{}; while (index < name.size()) { ... (by Handy Andy)
Class Constructors And Initialization
 
Hello, I am trying to understand this code but I seem to be stuck. Hopefully you can help me understand https://www.boost.org/doc/libs/1_72_0/doc/html/boost...
[2 replies] Last: these are obviously functions Do you mean this class: class server ... (by keskiverto)
Input and output, binary file
 
In this code i am not able to perform reading operation. In addition after writing data it itself assumes value of 'a' as ' ' and the loop ends. Code written a...
[1 reply] : https://www.cplusplus.com/forum/beginner/269215/ Pay attention to the ... (by salem c)
Doubt in basic file handling
 
I wrote this code but not able to get desired result. It runs without any errors by compiler but ends unexpectedly with partially correct and incorrect data. Th...
[4 replies] Last: Thanks a lot. (by sameer304)
Do while
 
Trying to work this example out of my textbook and don't understand why it functions correctly with inputs of a=3 b=7 but not with a=0 b=3. Am I missing someth...
[5 replies] Last: Hello dakotad8218, I have tested the program in the shell and in VS 2... (by Handy Andy)
by kmce
Global objects?
 
Hi, I have a question regarding objects. I have 4 classes that, in my main file, I need to create objects from. In the main.cpp file I have multiple functions t...
[3 replies] Last: Ok I understand now why creating them as globals would be a bad idea. ... (by kmce)
Retrieve vector content for a special type
 
Hello, given I am saving content to a vector std::vector<IP> list, how can I retrieve all the content in the vector? I am trying this: void IPManager::c...
[1 reply] : I don't know what an "IP" is. Is your class? Is it someone else's clas... (by helios)
by R0SsAN
Fastest way to import a text file
 
Hi, I'm writing a program that takes txt files as input and looks for strings in them. Until now I have used the getline command while (getline(lsass, line...
[10 replies] Last: Hardware is getting to be amazing. I redid mine. If you run it as... (by jonnin)
April 2020 Pages: 1... 17181920
  Archived months: [mar2020] [may2020]

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