well i have been working on my program and i have some books on c++ and stuff.
I have made my program but the button dos not work and i put the Functional code in but it did not work.
i want my program to Generate random letters and numbers
a-z and 0 - 9
its a Random Key Generator ( 4 numbers and 14 letters )
e.g : 1GEN-6HKE-8IJC-0FOE
my program ( without the Functional code my program works fine but the button and the text boxes dos notting lol)
so can you help me make my code or do you have some tips or links i can have ect
note:
My program has no Functional code for the button to make A key code Generator coz the Funcitonal codes in my college books dont work lol + i tryed to edit it to get it to work.
I need help with my program coz im too dum and its in c++?
You will get more help at http://www.codeguru.com
Reply:Have a look here http://www.cprogramming.com/tutorial.htm...
Reply:This would depend on what IDE you are using. VC++?? Borland ?? what. Each one has a different way of using controls on a form and initiating them. They are usually subclassed classes of the form type and you will have to give them variable names and functions in order to make them do what you want.
Reply:You don't just copy code around, you have to write code!
Note, also, that your sample code has 4 numbers and *12* letters, not 14.
Given the sample I would make a routine that returned a random number, another that returns a random letter, a third that calls the first once and the second 3 times to build a group and then a fourth that calls the third 4 times to build the result.
Routines 3 and 4 could use loops but personally I would not do so.
Sunday, August 2, 2009
Two different HELLO WORLD programs in c++ what's the difference?
The code doesn't seem to display right in Yahoo Answers so I will just post the link to the site I asked this question on. The link takes you directly to the comment I made, which is by the username Wesley. (Random name I thought of)
http://www.learncpp.com/cpp-tutorial/06-...
You can respond to the comment on the site or directly here in Yahoo Answers.
Reason for asking:
The C++ book I ended up buying shows the code like that and also other codes. Instead of what I'm used to.. cout %26lt;%26lt; "Hello world"
it's some other ****.
Two different HELLO WORLD programs in c++ what's the difference?
if you pick the "namespace std" then you don't put std in it.
cout %26lt;%26lt; "Hello World!n"; //don't put std if you use namespace std (that is standard namespace.)
Howerver if you not pick a "namespace std" then put std in it. such as:
std::cout %26lt;%26lt; "Hello World!n"; // you must put std if don't pick namespace std;
Reply:The true beauty of computer programming is that there are many ways of providing a valid solution. The difference you are seeing is with the standard namespace.
Namespaces allow you to give a "possession" to written code. For instance, if you write a function and Chuck Norris writes a function, you can each put it in your own namespace. Say if Norris wants to use your function, he will include your namespace, so when he's using it, he will know to whom the code belongs. It is used often in work environments.
In C++, you can use the standard namespace by writing the statement
using namespace std;
or you can use std:: with each statement that is part of the namespace. As you will see in programming with the standard namespace, it is good practice to use the single line above your main program. Try out each way and get accustomed to different code, because as you will see, everyone writes their code differently.
Reply:Many functions and objects in C++ are standard and are contained in the standard library. Neither example is wrong. To help clarify your confusion, you should look up namespaces and the using statement, as well as the scope resolution operator ::. This is probably beyond your understanding, but cout is an ostream object. At this point, don't be too concerned about that, but think of it like a variable that is declared. Now, say by accident you made a variable called cout (eg. int cout;). How would the compiler know which cout that you are referring to? Well, through the use of namespaces, one can put all their created objects and variables in a namespace. cout happens to reside in a namespace called 'std', which is short for standard. 'endl' is also in there. The proper way to use a namespace is to put the namespace, followed by the scope resolution operator ::, then the name of the object (eg. std::cout, std::cin, std::endl). However, this can beome cumbersome in a large program. The way to save some typing is with the using statement. There are a few ways to use this statement. One can use it locally in a function or globally. Many people will use the std namespace globally, so at the top of their program after the includes, you will see " using namespace std;" This means anything in that namespace, you will not need to put std:: infront of it, though you still can.
So you can do helloworld either way:
using namespace std;
int main()
{
cout %26lt;%26lt; "Hello World!" %26lt;%26lt; endl;
// you can still even do std::cout with
// the using namespace std; statement
return 0;
}
or
int main()
{
std::cout %26lt;%26lt; "Hello World!" %26lt;%26lt; std::endl;
return 0;
}
http://www.learncpp.com/cpp-tutorial/06-...
You can respond to the comment on the site or directly here in Yahoo Answers.
Reason for asking:
The C++ book I ended up buying shows the code like that and also other codes. Instead of what I'm used to.. cout %26lt;%26lt; "Hello world"
it's some other ****.
Two different HELLO WORLD programs in c++ what's the difference?
if you pick the "namespace std" then you don't put std in it.
cout %26lt;%26lt; "Hello World!n"; //don't put std if you use namespace std (that is standard namespace.)
Howerver if you not pick a "namespace std" then put std in it. such as:
std::cout %26lt;%26lt; "Hello World!n"; // you must put std if don't pick namespace std;
Reply:The true beauty of computer programming is that there are many ways of providing a valid solution. The difference you are seeing is with the standard namespace.
Namespaces allow you to give a "possession" to written code. For instance, if you write a function and Chuck Norris writes a function, you can each put it in your own namespace. Say if Norris wants to use your function, he will include your namespace, so when he's using it, he will know to whom the code belongs. It is used often in work environments.
In C++, you can use the standard namespace by writing the statement
using namespace std;
or you can use std:: with each statement that is part of the namespace. As you will see in programming with the standard namespace, it is good practice to use the single line above your main program. Try out each way and get accustomed to different code, because as you will see, everyone writes their code differently.
Reply:Many functions and objects in C++ are standard and are contained in the standard library. Neither example is wrong. To help clarify your confusion, you should look up namespaces and the using statement, as well as the scope resolution operator ::. This is probably beyond your understanding, but cout is an ostream object. At this point, don't be too concerned about that, but think of it like a variable that is declared. Now, say by accident you made a variable called cout (eg. int cout;). How would the compiler know which cout that you are referring to? Well, through the use of namespaces, one can put all their created objects and variables in a namespace. cout happens to reside in a namespace called 'std', which is short for standard. 'endl' is also in there. The proper way to use a namespace is to put the namespace, followed by the scope resolution operator ::, then the name of the object (eg. std::cout, std::cin, std::endl). However, this can beome cumbersome in a large program. The way to save some typing is with the using statement. There are a few ways to use this statement. One can use it locally in a function or globally. Many people will use the std namespace globally, so at the top of their program after the includes, you will see " using namespace std;" This means anything in that namespace, you will not need to put std:: infront of it, though you still can.
So you can do helloworld either way:
using namespace std;
int main()
{
cout %26lt;%26lt; "Hello World!" %26lt;%26lt; endl;
// you can still even do std::cout with
// the using namespace std; statement
return 0;
}
or
int main()
{
std::cout %26lt;%26lt; "Hello World!" %26lt;%26lt; std::endl;
return 0;
}
The school editorial staff does a feature article in each issue on one student picked at random..............?
The school editorial staff does a feature article in each issue on one student picked at random. The chart shows the mumber of male and female students for each grade . What is the probability that the student chosen will be either a 9th or 10th grade female?
(nrst 1000th)
Grade 9 Grade 10 Grade 11 Grade 12
m-240 m-180 m-160 m-165
f-190 f-205 f-200 f-210
a) 0.251
b)0.255
c)0.258
d)0.259
d)
The school editorial staff does a feature article in each issue on one student picked at random..............?
Total students = 1550
female 9th and 10th graders = 395
395/1550 = .255
(nrst 1000th)
Grade 9 Grade 10 Grade 11 Grade 12
m-240 m-180 m-160 m-165
f-190 f-205 f-200 f-210
a) 0.251
b)0.255
c)0.258
d)0.259
d)
The school editorial staff does a feature article in each issue on one student picked at random..............?
Total students = 1550
female 9th and 10th graders = 395
395/1550 = .255
Should I learn Visual Basic or C# for programming with ASP .NET?
I've written the basics of a website log file analyzer in JavaScript that due to the language's restrictions cannot process a real log in a reasonable amount of time. (Apparently the random 10-12ms lags cause execution time to quadruple when the dataset is doubled.)
I'm interested in learning ASP .NET to realize my project, but I don't know which supported language is going to calculate the statistics faster, Visual Basic or C#.
I'm also interested in which of the languages is closer to emulating the JavaScript string functions as well as which is preferred by developers.
Should I learn Visual Basic or C# for programming with ASP .NET?
Visual Basic is obsolete. Go with C#, ASP.NET or even better WPF
spring flowers
I'm interested in learning ASP .NET to realize my project, but I don't know which supported language is going to calculate the statistics faster, Visual Basic or C#.
I'm also interested in which of the languages is closer to emulating the JavaScript string functions as well as which is preferred by developers.
Should I learn Visual Basic or C# for programming with ASP .NET?
Visual Basic is obsolete. Go with C#, ASP.NET or even better WPF
spring flowers
Using spawnl and _pipe in c to make two children processes?
I have a project that I have to create a parent process with two children processes using spawnl and _pipe in c. I been looking all over the net for a easy toturial but no luck. So I hoping someone here can help. I need one child to count from 1 to 49 showing only odd numbers and the second child to count for 2 to 50 showing only even numbers. The parent process needs to go back and forth between the two child processes with a random pause between them using sleep. This really has me stumped. Any help would be greatly appreciated.
Using spawnl and _pipe in c to make two children processes?
So, the only problem here is that you don't know how to use the spawn and pipe functions?
Or you're having problems with the whole algorithm?
If you write the program in pseudo-code, you can figure out the algorithm quite easily. From your pseudo-code, you can figure out which C functions you will need. For example, since you need a random pause, you'll need to use something like rand() to make a random number. If you use rand(), you'll also have to use another function to seed rand(), otherwise, rand() will always come up with the same numbers each time you run the program.
I'm not going to do your homework for you by providing a complete program, or telling you how to make the algorithm. There are plenty of code examples for spawnl in web sites and there forums if you do a Yahoo! or Google search. If you're having trouble, you should post your code and ask for a solution to a particular problem.
Hint:
When you're learning new functions, first write a small test program with them to see if you can get it working. After that, you then work the functions into the program that you're making. Often, you can just copy %26amp; paste the code between the source files.
Using spawnl and _pipe in c to make two children processes?
So, the only problem here is that you don't know how to use the spawn and pipe functions?
Or you're having problems with the whole algorithm?
If you write the program in pseudo-code, you can figure out the algorithm quite easily. From your pseudo-code, you can figure out which C functions you will need. For example, since you need a random pause, you'll need to use something like rand() to make a random number. If you use rand(), you'll also have to use another function to seed rand(), otherwise, rand() will always come up with the same numbers each time you run the program.
I'm not going to do your homework for you by providing a complete program, or telling you how to make the algorithm. There are plenty of code examples for spawnl in web sites and there forums if you do a Yahoo! or Google search. If you're having trouble, you should post your code and ask for a solution to a particular problem.
Hint:
When you're learning new functions, first write a small test program with them to see if you can get it working. After that, you then work the functions into the program that you're making. Often, you can just copy %26amp; paste the code between the source files.
In June 2005, a CBS News/NY Times poll asked a random sample of 1111 U.S. adults the following question: "What
In June 2005, a CBS News/NY Times poll asked a random sample of 1111 U.S. adults the following question: "What do you think is the most important problem facing this country today?" Roughly 19% of those sampled answered "The war in Iraq" (while the rest answered "Economy/Jobs, Terrorism, Healthcare, etc."). Exactly a year prior to this poll, in June of 2004, it was estimated that roughly 1 out of every 4 U.S. adults believed (at that time) that the war in Iraq was the most important problem facing the U.S.
We would like to test whether the 2005 poll provides significant evidence that the proportion of U.S. adults who believe that the war in Iraq is the most important problem facing the U.S. has decreased since the prior poll.
The following output is available for this test:
The output indicates that: (choose the best answer)
(a) we have extremely strong evidence to reject Ho.
(b) we have extremely strong evidence to reject Ha.
(c) we have moderately strong evidence to r
In June 2005, a CBS News/NY Times poll asked a random sample of 1111 U.S. adults the following question: "What
it was 19% in 2005 who felt war was most important
it was 1 in 4 = 1/4 = .25 = 25% in 2004 who felt war was important.
It clearly decreased by 6% since the previous poll.
I don't know what Ho or Ha or r is.
We would like to test whether the 2005 poll provides significant evidence that the proportion of U.S. adults who believe that the war in Iraq is the most important problem facing the U.S. has decreased since the prior poll.
The following output is available for this test:
The output indicates that: (choose the best answer)
(a) we have extremely strong evidence to reject Ho.
(b) we have extremely strong evidence to reject Ha.
(c) we have moderately strong evidence to r
In June 2005, a CBS News/NY Times poll asked a random sample of 1111 U.S. adults the following question: "What
it was 19% in 2005 who felt war was most important
it was 1 in 4 = 1/4 = .25 = 25% in 2004 who felt war was important.
It clearly decreased by 6% since the previous poll.
I don't know what Ho or Ha or r is.
Friday, July 31, 2009
This is a joint PDF question. (c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
a random variable Y has probability function P(Y=2)= 0.6, P(Y=3)=0.2 and P(Y=4)=0.2.
once Y has been observed, Y fair coins are tossed; let X denote the number of heads which are observed.
(a) Write downt the conditional expectation of X given Y= y, for each y=2,3,4.
hence express E[X l Y] as a function of Y.
(b) Find E(Y) and use this to calculate E(X).
(c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
(d) find the marginal probability function of X and verify that the expectation of this distribution agrees with the value calculated in (b)
This is a joint PDF question. (c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
.. X ....... 0 ................. 1 ................ 2 ................ 3 ............... 4
Y=2 . (.25)(.6) ...... (.5)(.6) ........ (.25)(.6) ............ 0 .............. 0
3 .... (.125)(.2) .... (.375)(.2) ...... (.375)(.2) ..... (.125)(.2) ...... 0
4 ... (.0625)(.2) ..... (.25)(.2) ... (.375)(.2) . (.25)(.2) . (.0625)(.2)
If y = 2, 0 head: 1/4 , 1 head: 2/4, 2 heads: 1/4 (then multiply 0.6)
If y = 3, 0 H: 1/8 , 1H: 3/8 , 2H: 3/8 , 3H: 1/8
If y = 4: 0H: 1/16, 1H: 4/16 , 2H: 6/16 3H: 4/16 4H: 1/16
Also, E[Y] = 2*.6 + 3*.2 + 4*.2 = 2.6
I had now given you the table. Multiply to get the values and use that to determine the rest of the answers. ©
Reply:a)
E[X|Y=2] = 0.5*2 = 1
E[X|Y=3] = 0.5*3 = 1.5
E[X|Y=4] = 0.5*4 = 2
E[X|Y=y] = 0.5*y
b)
E[Y] = 2*0.6 + 3*0.2 + 4*0.2 = 2.6
E[X] = E[ E[ X|Y ] ] = Sum over all y of E[X|Y=y]P[Y=y]
= 1 * 0.6 + 1.5 * 0.2 + 2 * 0.2 = 1.3
c)
These are all found using the binomial distribution and mulitplied by P[Y=y]
Y = y | 2_________3___________4_______total P[X= x]
X = 0 | 0.25*0.6____0.125*0.2____0.0625*0.2
X = 1 | 0.5*0.6_____0.375*0.2____0.25*0.2
X = 2 | 0.25*0.6____0.375*0.2_____0.375*0.2
X = 3 | 0_________0.125*0.2_____0.25*0.2
X = 4 | 0_________0___________0.0625*0.2
total P[Y=y]
to finish the table sum the columns to get P[Y=y] and sum the rows for P[X=x]
once Y has been observed, Y fair coins are tossed; let X denote the number of heads which are observed.
(a) Write downt the conditional expectation of X given Y= y, for each y=2,3,4.
hence express E[X l Y] as a function of Y.
(b) Find E(Y) and use this to calculate E(X).
(c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
(d) find the marginal probability function of X and verify that the expectation of this distribution agrees with the value calculated in (b)
This is a joint PDF question. (c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
.. X ....... 0 ................. 1 ................ 2 ................ 3 ............... 4
Y=2 . (.25)(.6) ...... (.5)(.6) ........ (.25)(.6) ............ 0 .............. 0
3 .... (.125)(.2) .... (.375)(.2) ...... (.375)(.2) ..... (.125)(.2) ...... 0
4 ... (.0625)(.2) ..... (.25)(.2) ... (.375)(.2) . (.25)(.2) . (.0625)(.2)
If y = 2, 0 head: 1/4 , 1 head: 2/4, 2 heads: 1/4 (then multiply 0.6)
If y = 3, 0 H: 1/8 , 1H: 3/8 , 2H: 3/8 , 3H: 1/8
If y = 4: 0H: 1/16, 1H: 4/16 , 2H: 6/16 3H: 4/16 4H: 1/16
Also, E[Y] = 2*.6 + 3*.2 + 4*.2 = 2.6
I had now given you the table. Multiply to get the values and use that to determine the rest of the answers. ©
Reply:a)
E[X|Y=2] = 0.5*2 = 1
E[X|Y=3] = 0.5*3 = 1.5
E[X|Y=4] = 0.5*4 = 2
E[X|Y=y] = 0.5*y
b)
E[Y] = 2*0.6 + 3*0.2 + 4*0.2 = 2.6
E[X] = E[ E[ X|Y ] ] = Sum over all y of E[X|Y=y]P[Y=y]
= 1 * 0.6 + 1.5 * 0.2 + 2 * 0.2 = 1.3
c)
These are all found using the binomial distribution and mulitplied by P[Y=y]
Y = y | 2_________3___________4_______total P[X= x]
X = 0 | 0.25*0.6____0.125*0.2____0.0625*0.2
X = 1 | 0.5*0.6_____0.375*0.2____0.25*0.2
X = 2 | 0.25*0.6____0.375*0.2_____0.375*0.2
X = 3 | 0_________0.125*0.2_____0.25*0.2
X = 4 | 0_________0___________0.0625*0.2
total P[Y=y]
to finish the table sum the columns to get P[Y=y] and sum the rows for P[X=x]
Subscribe to:
Posts (Atom)