[Home] [Manage]

Name
Email
Subject   (new thread)
Message
File 
Embed   [?]
Password  (for post and file deletion)
  • Supported file types are: GIF, JPG, PDF, PNG, RAR, ZIP
  • Maximum file size allowed is 1000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 272 unique user posts. View catalog
  • User Moderation is disabled

File: 122386683818.gif-(195.82KB, 183x245, dancing girl.gif)
834 No. 834 Stickied hide watch expand quickreply   [Reply]
I toasted this a while ago, but it has since disappeared, and I believe it's worth toasting again.

http://www.51cnnet.com/directory

If you would like to learn a programming language, or several, or any number of computer-related subjects, go to that site and find an e-book you like. There are several thousand to choose from.
15 posts and 3 images omitted. Click Reply to view.
>> No. 1684
http://freecomputerbooks.com/
>Free Computer, Mathematics, Technical Books and Lecture Notes, etc.


File: 121410765664.jpg-(12.59KB, 344x226, 120212100161.jpg)
40 No. 40 Locked Stickied hide watch quickreply   [Reply]
Rules of /pr/
1. This is not /prog/
2. Do not be a faggot


File: 125849510751.jpg-(74.38KB, 600x317, 12519095178.jpg)
2158 No. 2158 hide watch expand quickreply   [Reply]
Just a real quick, but stupid question, /pr/...

How come when using the POW function from cmath.h, you have to use doubles to use the function?

For example:

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
double x = 5, y = 3;
double z = pow(x,y);
cout << x << " ^ " << y << " = " << z << "";
Message too long. Click here to view the full text.
1 post omitted. Click Reply to view.
>> No. 2160
I'm sorry but I have no idea what you're talking about. I'm still relatively new to C++. The most advanced thing I was able to code was a password generator, and that was just using a while loop with a character string array to pull a random character from the array while the amount of characters was less than or equal to the amount of characters the user specified... then it outputs the password to a file.
>> No. 2161
>>2159
Implicit casts: int > float > double (also for short and long). It'll generate a warning if you pass a double instead of an int.
>> No. 2162
>>2160
casts are essentially converting the datatype.
Converting up is fine - an integer will always fit in the range of a double, but a double won't always fit into an int


File: 125788975762.png-(5.46KB, 376x270, 1257800815463.png)
2138 No. 2138 hide watch quickreply   [Reply]
Hello /pr/. I'm working on a program that will convert between Celsius and Fahrenheit, and I'm having some trouble. The goal of the assignment is to learn how to write functions outside of int main() and call them within int main(). My problem is that the variable that I use for storing the starting temp doesn't seem to want to carry over to the functions (I get errors about it being undefined or no value set).

Here's the code. The offending variable is temp. Pic related - it's my reaction to this.


#include <iostream>
using namespace std;

double to_fahrenheit(){
double convertedTemp, temp;
convertedTemp = 9.0/5.0 * temp + 32;
return convertedTemp;
}

double to_celsius(){
Message too long. Click here to view the full text.
>> No. 2139
>double convertedTemp, temp;
>convertedTemp = 9.0/5.0 * temp + 32;
means
convertedTemp = 9.0/5.0 * TRASH + 32;
temp there is local to the function, it is NOT the same as main's temp.
you can either pass temp to the function (the right way), or use a global (don't do this). to pass an argument:
type0 function(type1 arg){...} - function that receives an type1 and returns type0.

Also read a book.
>> No. 2156
>>Also read a book.

Helpful :P

OP, look into parameters. You can use them to "pass" variables from your main method to your methods. They're brilliant :D
>> No. 2157
File: 125840689020.jpg-(20.48KB, 408x304, me.jpg)
2157
Precision with Doubles? Use BigDecimal, mate.


File: 125812993883.jpg-(28.03KB, 300x299, internet.jpg)
2150 No. 2150 hide watch quickreply   [Reply]
How do I even start this assignment? I don't get what I have to do. Please help.

Assignment:

Create XML for basic data about people. You must have at least 3 people and no more than 6 are allowed. Each person has an identification number, a name, an address, and anywhere from 0 to an unlimited number of occupations. The ID number is one field, the name is made up of a first name, a last name, and a middle initial which may or may not exist; the address is made up of street address, city, state, and zip code; and the occupations if they exist contain a job title, a salary and company. The fields identification number, first name, last name, street address, city, state and zip code must occur exactly once for each person.
>> No. 2152
XML must have a main opening and closing tag - data in this case. Then have some tags that specify fields, with the actual field data inbetween the tags

<data> <person> <id>5</id> <name>tim</name> <address> <city>New York</city> <zip>ta3wnf3q98y</zip> and so on... </address> and so on... </person> next person here... </data>


Job done.
>> No. 2155
XML can also have attributes, for example:
<person sex='female'>

But it really doesn't matter if you use attributes or fields.

<person>
<sex>female</sex>
</person>

Would mean the same thing. I just use fields for everything unless I have a good reason to use an attribute (Can't think of a good example right now)


File: 125633529911.png-(204.07KB, 509x380, 12517291062.png)
2095 No. 2095 hide watch expand quickreply   [Reply]
/pr/, I'm trying to write a program to convert Binary to Decimal... I only have two errors, but it's both about the same line and the same error, so I guess that's not bad for a first compile. I can't for the life of me figure out what's wrong... here's the code for the program...

// Binary to Decimal Converter. Programmed by Anonymous.
#include <iostream> // Include input/output stream header.
#include <cstdlib> // Include the C standard library header.
using namespace std; // Use the standard namespace.

char chUserInput[8];
int decValue = 0;
int count;

void checkValue() {
if(chUserInput[1] == 1) {
decValue = decValue+128;
}
Message too long. Click here to view the full text.
8 posts omitted. Click Reply to view.
>> No. 2135
>>2125

GTFO, VBfag...

(USER WAS OXYCLEANED FOR THIS POST )
>> No. 2153
>>2113
#include "stdio.h" #include "string.h" int main(int argc, char* argv[]) { if (argc == 2) { long bten_valu = 0; int btwo_lenx = strlen(argv[1]) - 1; for (int btwo_pntr = 0;btwo_pntr <= btwo_lenx;++btwo_pntr) { bten_valu += ((argv[1][btwo_pntr] == '1') << (btwo_lenx - btwo_pntr)); } printf("%d", bten_valu); return 1; } return 0; }


Improved for you bro.
>> No. 2154
>>2153
Don't you want stdio.h and string.h inside <>, instead of ""?


File: 125813225734.jpg-(24.39KB, 424x253, lol.jpg)
2151 No. 2151 hide watch quickreply   [Reply]
I dont know how to do this assignment. Please tell me what they are asking. Thank you.

assignment:

Create XML for basic data about people. You must have at least 3 people and no more than 6 are allowed. Each person has an identification number, a name, an address, and anywhere from 0 to an unlimited number of occupations. The ID number is one field, the name is made up of a first name, a last name, and a middle initial which may or may not exist; the address is made up of street address, city, state, and zip code; and the occupations if they exist contain a job title, a salary and company. The fields identification number, first name, last name, street address, city, state and zip code must occur exactly once for each person.


File: 125793976526.jpg-(49.03KB, 400x300, 1237468315682.jpg)
2143 No. 2143 hide watch quickreply   [Reply]
Hi /pr/

I'm not really into programing and all, but I was just curious about the way of key-generator works. How can random number be validate by a program ? this is a bit unlogical I guess...

Can someone explains to me how this is working
? thx

pic unrelated
>> No. 2145
It isn't random. It's similar to how you check if a credit card is valid, you pass the number through some function and check if the result is valid (e.g. add all digits and check if the result is a multiple of 9; credit cards use this: http://en.wikipedia.org/wiki/Luhn_algorithm). In the case of serial numbers it may involve the username too.
>> No. 2147
wow thanks skippy nigga ! I didnt knew it works that way.
I finally get my response thanks to you
>> No. 2149
I think the most important thing to remember about a pseudo-random number generator is that when all variables but the input variable remain constant. The number generated by the function will eventually always repeat


File: 124471234177.jpg-(45.67KB, 520x413, 123904805534.jpg)
1657 No. 1657 hide watch expand quickreply   [Reply]
Did /pr/ learn more from a teacher or a textbook
28 posts and 1 image omitted. Click Reply to view.
>> No. 2127
>>1668
It all depends on your ability to assimilate information, of various types. Some people are more intelligent and dont need to be force fed by some lecturer.
>> No. 2128
>>1674
>There's no self-taught programmers in big software companies.
I wrote Nikes POS system, tell that to the birds
>> No. 2148
I must say teacher gave it a little push towards the right direction.


File: 125796842073.jpg-(13.18KB, 369x337, 5e_037MultiPass.jpg)
2144 No. 2144 hide watch quickreply   [Reply]
/pr/... programming newfag here. Actually been doing C++ for a while, but never moved past the basics... I designed a form in Visual Studio 2008... how do I assign integers to the text typed in a text box and do something when the button I put in there is clicked?


Delete Post []
Password  
[Mod]
Previous[0] [1] [2] [3] [4] [5] [6] [7] [8]