c++ learning and comprehension
#41
Posted 10 March 2007 - 03:06 AM
1 + 2 + 3 + 4 + 5
which equals 15.
#42
Posted 10 March 2007 - 04:46 AM
#43
Posted 10 March 2007 - 11:02 AM
//edit
Could use a formula instead... print n, ((n+1)*n)/2
seems to work..
Edited by PurpleJesus, 10 March 2007 - 01:10 PM.
#44
Posted 10 March 2007 - 02:00 PM
Yeah, I saw that it was adding up the sum of individual digits ... but I couldn't figure out what the testing of max against a negative number was all about... That part threw me for a moment.
//edit
Could use a formula instead... print n, ((n+1)*n)/2
seems to work..
yes, you can (and in 'real life' probably should), but the point was for spongebob crazypants up there to get practice with functions and loops and whatnot.
Edited by rainwater_stillicide, 10 March 2007 - 02:01 PM.
#45
Posted 10 March 2007 - 08:41 PM
also how is it that script kiddies get anything done i've tried hacking while others products , like brutus, shadow scan, nmap (nmap is a awesome port scanner), metasploit but i never get anything done could someone explain to me more about ports and ips or if they don't have the time to point me to a good tcp/ip document thanks
#46
Posted 10 March 2007 - 10:00 PM
Hi im spongebob crazypants, but that pseudo code confused the hell out of me about functions. So could someone else explain it to me a lil better.
also how is it that script kiddies get anything done i've tried hacking while others products , like brutus, shadow scan, nmap (nmap is a awesome port scanner), metasploit but i never get anything done could someone explain to me more about ports and ips or if they don't have the time to point me to a good tcp/ip document thanks
Read your 15 C++ books, I guarantee they tell you exactly how functions work.
#47
Posted 10 March 2007 - 10:15 PM
Read your 15 C++ books, I guarantee they tell you exactly how functions work.
You don't let up, do you?
What we're all trying to get at is: read about them yourself. A function is not a difficult concept. You should have moved past functions within your first hour or two of learning. If you don't have the ambition to learn something so simple for yourself, no one is going to waste their time helping you. Why should they, you're just going to turn around and ask another question you'd know the answer to if you read your 15 (sorry, couldn't help myself) C++ books.
Edited by Ohm, 10 March 2007 - 10:16 PM.
#48
Posted 10 March 2007 - 10:44 PM
#49
Posted 10 March 2007 - 10:59 PM
#50
Posted 10 March 2007 - 11:09 PM
#51
Posted 11 March 2007 - 12:32 AM
how does everyone here or on rohitab.com generate so much unique coe and know so much about the c++ lang. when all of the examples in ebooks or tutorials are all the damn same i/o or string handling you talk about win sock and api hooks and all of this stuff and when beginners ask how do you do it alot of the time google well im asking how do you find this info out is there some magical thing, i have some source code and it is amazing but i can't understand how exactly it works i know what each part basically does so all im asking is how do you find out about more practical programming
You don't learn to be a good coder. Good coders are good coders. Basically they do it because their imagination (and skill) is essentially limitless. Your not gonna go anywhere, or learn anything through mindless droning through ebooks, tuts, and white papers. You have to understand what they are doing and take it slow enough so you understand it's uses. I help a kid weekly on C++ and he sounds exactly like you. What I did to learn was this. I went through the book and typed out all the examples. I did the tests at the end of the chapter and then read about the different things it's used for on the internet. Then when I finished a chapter I made a program using the knowledge from the previous sections and the current chapter all off my own ideas. That's what I believe taught me to be a practical programmer. It sounds like you think you know what you are doing, but you have no clue how to implement it in the real world. Maybe take on a few coding projects to ease your way into more practical programming through other's ideas.
It's all your imagination my friend and if your a hacker, you probably have one hell of one.
Edited by deadc0de, 11 March 2007 - 12:34 AM.
#52
Posted 11 March 2007 - 12:48 AM
Read your 15 C++ books, I guarantee they tell you exactly how functions work.
You don't let up, do you?
What we're all trying to get at is: read about them yourself. A function is not a difficult concept. You should have moved past functions within your first hour or two of learning. If you don't have the ambition to learn something so simple for yourself, no one is going to waste their time helping you. Why should they, you're just going to turn around and ask another question you'd know the answer to if you read your 15 (sorry, couldn't help myself) C++ books.
Nope, there's no point in giving up.
While you "read" 15 books on C++, you seem to lack an extremely basic understanding of it so I'm not wondering if actually read them, I'm wondering if you only read the parts that showed code and tried to learn by only reading that.
Honestly, understanding functions is simple. As Ohm said, you should have gotten past them in the first hour or two of reading and gained a working knowledge of them. But apparently, out of all 15 books, they're written so complex only experienced programmers can read them and the beginners books are "too" dumb (hint: there is never TOO dumb) for you to bother with.
Go back and read or admit that you really don't understand any of it and politely (read: without your ego) ask for help.
#53
Posted 11 March 2007 - 01:39 AM
#54
Posted 11 March 2007 - 03:21 AM
well im not trying to seem like i have a big ego but i know the way i learn and no i read them i don't just look at the preety pictures of code i do lack a basic comprehension of functions and everyting the guy who replied before you helped more then any one else he understood the title of this discussion and that is how everyone else learnt and what helped them with learning and comprehension of the different data types and features of c++ i don't have to stroke my ego online im asking for simple help with by finding out what helped you. i read the books over and over again the more i read the less i understand
Is it me or are the last few posts essentially the same thing where he whines and keeps pushing for someone to explain the basic concept of a function?
Have you tried writing a simple function and then trying to use it in different ways so maybe you would learn visually and from practical experience? That helps me sometimes.
Maybe something like : (Excuse my java)
int Add(num1, num2) {
return num1+num2;
}and then using that function as a part of a larger code?
Maybe you could get two numbers, execute the function, and then print out the value of the function?
That would be a simple program.. I really don't know how to explain it any simpler.
#55
Posted 11 March 2007 - 03:42 AM
int add(num1, num2){
return num1 + num2;
}
main()
{
int num1, num2;
cin >> num1;
cin >> num2
add();
cout << add();
return 0;
}hold on i m going to run this real quick
#56
Posted 11 March 2007 - 03:55 AM
#57
Posted 11 March 2007 - 04:40 AM
#include <iostream> //1
using namespace::std; //1
int add(int num1, int num2){ // 4
return num1 + num2;
}
main()
{
int num1, num2;
cin >> num1;
cin >> num2; //2
cout << add(num1, num2); //3
return 0;
}This is a working version of the code you posted.
The changes have been numbered in the comments:
1. didn't import iostream so the program couldn't use cin or cout
2. no semi-colon on the line: cin >> num2
3. called add with no arguments.
The function is delcared with two arguments: int add(int num1, int num2)
so when you call it you need to supply two ints in the brackets: add(3, 4) or add(num1, num2)
4. no types given for arguments in function delceration (you need to write the types of the input that the function)
When a function is declared it needs to know what type of arguments to expect:
int add(num1, num2) doesn't tell it what num1 and num2 are, they might be ints but they could just as easily be characters or anything else.
you need to write:
int add(int num1, int num2) so that it knows to expect ints.
#58
Posted 11 March 2007 - 04:58 AM
#59
Posted 11 March 2007 - 05:02 AM
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}what are these arguments for
int main(int argc, char *argv[])
#60
Posted 11 March 2007 - 09:48 AM
ok thank you very much and when i ran it i fixed the semicolon problem and i re read the code and this helps uber mucho thank you so much
Ironically, after you've finally convinced someone to give you an example of a function, it looks exactly like (surprise!) examples you might find in your 15 C++ books. I don't mean to drone on and on here, but you did exactly what I said you would. Someone finally answered your question that could have easily been answered by reading your books, and then you turn around and ask another such question. The argc and argv variables are covered in your 15 C++ books.
BinRev is hosted by the great people at Lunarpages!


This topic is locked









