Beginners - February 2017 (Page 32)

I get a different answer to the correct answer when I run my code, my logic seems correct. not sure why?
 
I'm doing a series of excercises to get a better understanding of functions for college. I'm currently doing one now where "A function NumDays that may be pass...
[3 replies] Last: @joe864863 @jonnin That was a mistake by me in the question joe, I'm t... (by willmannix123)
Factorial of a number in C++
 
Personal contribution to open source C++. #include <iostream> using namespace std; // Program to find the factorial of a given number. void factorial (long...
[5 replies] Last: @jonnin: Why inline your function? It's also a good idea to mark your... (by mbozzi)
C++ Code not running properly and need some advice for my project! :)
 
Hello everyone. I'm a beginner, and need help with some code that wouldn't work when i ran it. Though when use the "run line by line" thing it works just fine. ...
[1 reply] : use the same function in main, you don't need 4 copies of it, that is ... (by jonnin)
prefix and post-fix using decrement operator C++
 
Personal contribution. #include <iostream> using namespace std; // Program to explain prefix and post-fix using decrementation. void functionOne (){ int a...
[no replies]
by wolfv
How to capture cerr from another program?
 
I wrote an application in C++ that throws exceptions, and catch sends error messages to cerr. Now I am writing a tester in C++ that calls the application. The t...
[5 replies] Last: I went with the example from JLBorges because it's so simple. The foll... (by wolfv)
Divisors
 
I have to write a program which displays how many divisors containing the digit "3" does the number entered have. When I introduce a number, nothing happens. ...
[4 replies] Last: Just playing with it... alternative approach char dtxt ; char * has3... (by jonnin)
Tips when tracing codes in an exam?
 
hey guys, im having a pretty hard time tracing codes in exams/quizzes and i was wondering if you guys could give me tips on how to trace and can anyone give me ...
[1 reply] : I do not know of a site, but this is a critical skill to debugging. ... (by jonnin)
using a class inside another class
 
Probably a noob mistake, but I do not find why my compiler gives me the following error : error: ‘sleep’ does not name a type in this code : #...
[1 reply] : Looks like you have a name clash with the POSIX sleep function. http:... (by Peter87)
Help with my homework
 
Hi there! I'm a beginner programming student and i was given this homework yesterday. im very confused and having a hard time making it run properly can you guy...
[5 replies] Last: hey thanks alot man, sorry i only got to replied now. i totally forgot... (by redhood)
Output list book
 
Hi everybody. I have code which output books. But I can't create database books to output a list. Where I must create this database? I think in class Book? But ...
[2 replies] Last: Yes I know. I was trying to create, but do not know how to connect thi... (by nfnicolas)
by Nalrie
Guess my number
 
I got really confuse on putting in arguments for the getUserResponseToGuess() function. I don't really know what to put into that argument. I wanted the user to...
[1 reply] : I am not sure, but maybe you should be thinking about random numbers b... (by Kourosh23)
initialising a pointer with a function address
 
How to create a pointer to void function? int sq(int num) { return num*num; } int kub(int num) { return num*num*num; } void central(int num, int(*p)(int)...
[8 replies] Last: Thx guys this helped a lot i get it now :D (by spax1111111)
transfering inputFile to vector c++
 
We're supposed to Write a program that reads an unknown number of integers from a data file called “data.txt” into a vector of integers named V. V is initia...
[2 replies] Last: Thanks it worked ! (by sesslit805)
Returning value with template function?
 
I'm not sure if the title makes sense, however, this code was working when i had the function returning the index number of the highest value. When i then chang...
[6 replies] Last: Oh! Awesome, I get it now! Thank you! (by Zerdalias)
by rantiv
Single If statement
 
I have to turn in my code and just realized one of the requirements is to have just one single if statement. I have a lot of nested if statements and cant figur...
[7 replies] Last: Once you see it, it's dead simple: The first thing I would do is corr... (by mbozzi)
Hybrid Car
 
It is supposed to look like this but for some reason when I enter (total) my code just stops. Im not really sure what I am doing wrong. I know this is a big que...
[1 reply] : @sandoda You're program worked fine for me. I used all the inputs you... (by whitenite1)
stoi
 
hey, just some question, what if stoi has an error ? does it return boolean like sstream ? because I failed at using stoi for something I succeed with sstream...
[2 replies] Last: thanks :) (by Flaze07)
Im not sure on how to pass an array through reference without using pointers.
 
Hi I need help in learning how to pass an array without using pointers and this is a homework assignment. I already have the first part of this hw assignment do...
[1 reply] : #include <iostream> const int arraySize = 5; int main() { int ... (by gunnerfunner)
by HRubss
y always equals 1?
 
So it's my 3rd day of programming class and I'm having troubles with my program assignment. The assignment is listed in the comment. Everything ran fine when I ...
[5 replies] Last: /*write a program that asks the user to enter an integer x. Based on... (by HRubss)
constant argument to a function
 
Personal Contribution to open source C++. Note: The purpose of adding const to your type and variable inside your argument is to catch errors if the user a...
[5 replies] Last: Yes. Ideally, limit the const qualifier to the implementation; at bes... (by mbozzi)
February 2017 Pages: 1... 3031323334... 37
  Archived months: [jan2017] [mar2017]

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