Beginners - April 2018 (Page 2)

Code Doesn't work
Problem was basically to output 2^n for any inputted integer n. I cannot see why my code doesn't work. It keeps outputting 2. #include <iostream> using...
Apr 30, 2018 at 2:21am
[1 reply] : Hello fat person, you are doing what's known as shadowing a variable... (by Ganado)
for loop: to draw a square a box
#include <iostream> using namespace std; int a; int b; int c; int main() { for(c=0;c<=5;c++) cout << " \t***" << endl; for(a=0;a<=5;...
Apr 30, 2018 at 12:36am
[1 reply] : Please use code tags when you want to post something formatted. Ex: [ ... (by Ganado)
by vcref
Runtime error sum of fractions
I have to sum two fractions and simplificate them. It works for some cases, but the system gives me a "Runtime error" when I submit. Any help? #include ...
Apr 30, 2018 at 12:32am
[6 replies] Last: ... (by vcref)
calculation error
Write your question here. #include <iostream> using namespace std; int main() { int a, b, c; cout << "enter"<<endl; cin >> a >> b >> c; ...
Apr 29, 2018 at 11:36pm
[3 replies] Last: It does display something, or not display something, depending on the ... (by zaphraud)
Fixing memory leak
I'm having trouble fixing a memory leak in my code. Based on using valgrind, the memory leak is occurring on line 6 in the Student constructor, but I'm not sure...
Apr 29, 2018 at 11:13pm
[8 replies] Last: Thank you for all the help. I was able to fix the memory leaks. (by qwerty123456)
Rotating square matrix many times!
Hello everyone! Here I have a code that rotates the square matrix clokcwise and I am trying to do that I can rotate it k times (k is inputed by the user). I tri...
Apr 29, 2018 at 9:04pm
[1 reply] : #include <iostream> #include <iomanip> #include <vector> using namesp... (by lastchance)
splitting input from cin
#include <iostream> #include <vector> #include <cctype> using std::string; using std::vector; using std::cin; using std::cout; using std::endl; ...
Apr 29, 2018 at 8:25pm
[2 replies] Last: I get it now, thank you so much tpb (by alfie nsugh)
Subtracting two doubles gives an odd result
Hi I've run the following code: double d = 342.389; double d_d = d - floor( d); //whats the decimal value i.e. 0.389 double n1 = d_d * 1000;...
Apr 29, 2018 at 7:27pm
[3 replies] Last: You can use an epsilon value. bool almost_equal(double a, double b,... (by Ganado)
Having Trouble Reading a text file and assigning data to different variables/arrays
I'm Sorry for the huge message, I figured It would make it easier to understand if you actually saw the assignment. I am only having difficulty with one specifi...
Apr 29, 2018 at 3:53pm
[7 replies] Last: I cannot Thank You enough for your help. Learning Coding has been quit... (by Mjimmie1)
multiplication of matrices using vectors
i am trying to multiply 2 matrices (src) & (src_trans) by passing matrices(2d vectors) to the function. the output is showing only 0's in the product of these ...
Apr 29, 2018 at 3:36pm
[1 reply] : Hints: #include <iostream> #include <vector> constexpr unsigned ROW... (by Enoizat)
C++ bandwidth with functions
Hi guys, I made-up this program with no intended purpose. However, I noticed that setting a band width (setw(2)) doesn't work with functions. Any idea why this ...
Apr 29, 2018 at 10:54am
[1 reply] : doesn't work “doesn't work” isn’t a good description of an iss... (by Enoizat)
How to write the sum of counter[i] using for loops.
Im a newbie. And i want to know how can i add up the sum of array using a for loop and stop until a number. E.g. i want to add up these counter until a number,...
Apr 29, 2018 at 9:41am
[5 replies] Last: //So if i input let say 15 alphabet, the middle one is 8. this could... (by closed account SECMoG1T)
Theater Ticket Sales Project
When i run the program it runs into an error when displaying. mostly in the seatarrArrangment fuction and it displays odd characters other than the ones in the ...
Apr 29, 2018 at 8:51am
[1 reply] : whenever you open a file it is your obligation to check if that file o... (by closed account SECMoG1T)
by hanes
Running only if statement, but not else
For some reason when I input 'y' it runs the if statement as intended but when I input something else, to trigger the else statement it runs the if statement in...
Apr 29, 2018 at 8:42am
[2 replies] Last: Ah, can't believe I overlooked me using the assignment operator there,... (by hanes)
Random Maze Generate
can you help me with this function? it's not working. looping infinitely. void Maze::generate(){ int width = 30; int height = 30; string str = ""; t...
Apr 29, 2018 at 7:05am
[5 replies] Last: Can you show the complete code we I can run it. (by Thomas1965)
Rounding Issue, Radian Angles and Distance
Noob Here. I have a problem where I have to round my outputs to 4 decimal places and I'm getting weird return values. I'm using this with all variables being ...
Apr 29, 2018 at 5:13am
[2 replies] Last: For your angle function use the two-parameter function atan2( y2, x2 )... (by lastchance)
Program crash
Hi there, I'm having trouble with my code. The program is supposed to take in a file and read in the values, the students names and their grades. However, the p...
Apr 29, 2018 at 12:37am
[5 replies] Last: Hello Drake5006, While testing the program I realized line 31. whi... (by Handy Andy)
help with function
https://www.geeksforgeeks.org/smallest-difference-pair-values-two-unsorted-arrays/ i have to make an assignment similar to this using recursive and vector and i...
Apr 28, 2018 at 10:18pm
[1 reply] : Seeing as you are using vectors, I would look into std::sort (...) : ... (by VX0726)
Please help
Ok, so I've got a lil' two player word guessing game where the first player enters a 5 letter word into the program and then the second player attempts to figur...
Apr 28, 2018 at 10:12pm
[1 reply] : The way I see it, you could store all of the guesses in the vector. Th... (by VX0726)
[C++] function pointers
Hi, I have a namespaced function inside a shared library: void foo::Bar() {}; If the code inside the shared library stores this function's address ...
Apr 28, 2018 at 9:46pm
[1 reply] : Yes. The loader loads code into the processes address space, and it's... (by kbw)
April 2018 Pages: 1234... 25
  Archived months: [mar2018] [may2018]

This is an archived page. To post a new message, go to the current page.
Registered users can post in this forum.