Beginners - May 2017 (Page 21)

How do you get the array after the third swap of bubble sort algorithm?
 
int jumbled2 = {5,9,50,6,1,70,0} It's in ascending order and the answer is 9,50,6,5,1,70,0. I don't understand why it looks like that though. How did 9 get ah...
[3 replies] Last: The original post: int jumbled2 = {5,9,50,6,1,70,0} It's in ascending... (by lastchance)
by arbwok
Question about struct
 
I can't understand why I can't create a constructor in struct. Is that only available for classes? struct a{ // Why does this not work? a(int ...
[3 replies] Last: Are you using C or C++? C doesn't have constructors. (by Peter87)
Help adding vectors to a vector of vectors
 
I need to add vectors to a vector of vectors, however, I don't know in advance how many vectors i need to add. #include<iostream> #include<vector> usi...
[5 replies] Last: max: nicely put, thank you. The new std::vector<int> syntax is from ... (by gunnerfunner)
by bibibi
source file split
 
How do I split this source file into suit multiple files? class Pane { protected : int width_, height_; int x_, y_; WINDOW *win_; public: P...
[1 reply] : Well, the obvious way would be to put each class definition into its o... (by MikeyBoy)
problem with huffman tree recreation
 
I have made up to this point a huffman compressor with the help from @TheIdeasMan and now i am working on the decompressor. I ran into a problem where i see t...
[9 replies] Last: Never mind no help is needed atm, i solved the problem. Once i finish ... (by globaltourist)
Doubt in template syntax
 
Hello I was reading an article about cpp templates, and I found this syntax given. template<class T, int N> int array_size(const T (&a) ) { retu...
[5 replies] Last: Thank you so much everyone. I was able to understand this one better. ... (by anantkaushik89)
How do you find the values of x and y?
 
void refVarFunc(int1 &Num1, int num2) { for (int1=0;i<5;i++) { num1++; num2 +=2; } } ---------------------------------------- int...
[4 replies] Last: I get it now. Thanks so much! (by imastruggler)
need check !
 
Write a program that keeps track the Lemonade sales for five weekdays: Monday, Tuesday, Wednesday, Thursday, and Friday. It should use two parallel five-elemen...
[1 reply] : What error message are you getting? The problems calls for an array o... (by wildblue)
Having a minor issue with my program
 
I'm working on a vending machine program but i'm having trouble getting it to output change correctly. My code is listed below, can someone point out what i'm ...
[4 replies] Last: Ah I see, thank you :) (by cplusplusnewb89)
by Caruso
two array's in Struct
 
I'm preparing for C++ institute exam. One of the questions is below. The outcome is 34 but I can't figure out why. I don't know how to approach this. Any body a...
[1 reply] : The topic is aggregate initialization. http://en.cppreference.com/w/c... (by mbozzi)
by dubley
Question about for loop increment
 
This program, from Stephen Prata's C++ Primer Plus, outputs 2! = 2, which I know is correct. But when I try to follow the logic of the program, I do not underst...
[2 replies] Last: I see. So in the program the first loop tests and executes all of the ... (by dubley)
Conway's game of life
 
I need some help with a project, we are working on class and i need to count a cell's neighbors to see how many of them are alive to determine if the next gen. ...
[no replies]
max() of two vectors
 
I thought max() function is to get the maximum between two values. But today I saw it can take in two vectors as below: vector<int> a,b,c; c=max(a,b); ...
[4 replies] Last: yes, it's a lexicographical compare, just like in a dictionary (by gunnerfunner)
by ATh
how to pass values of variable received from function A to function B
 
I am trying to pass value received by variable person and day from function getPersons(person1)and getDays(days1)to function advWeekend(person,day) i cannot see...
[3 replies] Last: I have updated the program the way i was expecting how it should work ... (by ATh)
How do I make formulas with exponenets?
 
How do I make formulas with exponenets? I want to make this into a formula, how do I go about it? W = 13.12 + 0.6215t - 11.37v^016 + 0.3965tv^0.016 ...
[4 replies] Last: Strongly favour std::sqrt() for finding the square root. http://en.c... (by JLBorges)
Array of 52, error with swapping values of indexes
 
#include <iostream> using namespace std; // swap function void xorSwap(int* x, int* y) { if (x != y) { *x ^= *y; *y ^= *x; *x ^= *y; } } int main() ...
[2 replies] Last: ... (by gunnerfunner)
Need a bit Pointer help
 
Hello every1.. i am trying to sort an array of n elements through pointers. While compiling it gives me this: Compiler & Linker output: Undefined reference to '...
[2 replies] Last: Thank you so much... (by learner47)
Writing programs using functions
 
My compsci professor is very kind, however... he is not the best professor and many of us are struggling with the concepts, seeing as we went from visual basic ...
[2 replies] Last: 1. Implement a function that returns an integer that is one greater t... (by Thomas1965)
Parse issue expected { or ,
 
I'm writing a derived class which calls the superclass constructor but im getting this issue and I cant seem to figure out why. It occurs at line 9 #include<s...
[9 replies] Last: I figured it out trying to copy the error lol, When i double clicked i... (by kingkush)
Constants and switch statement? - C++ beginner programming
 
Hi. I'm doing an assignment for school and it says that I must use constants for the menu choices. And I must use constants for Mets values and I also must us...
[1 reply] : #include <iostream> #include <iomanip> int main() { // use const... (by JLBorges)
May 2017 Pages: 1... 192021222324
  Archived months: [apr2017] [jun2017]

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