Sunday, August 2, 2009

How to go about writing a program in C for a Memory Card game?

Ok I am using c programming to program a game. 9 cards from ace to 9 of the same suit are to be displayed to the user in a random order and then asks the user to locate a specific card and the user has to locate the correct position, based on c programmin i plan to store the cards in an array. and when the user locates the card they will b giving the address of that card in the array.





Any ideas how i can go about doing this and most importantly how can i go about with the user interface of it?

How to go about writing a program in C for a Memory Card game?
Does not look easy, may be you can contact a C expert live at website like http://askexpert.info/ .
Reply:yes.


A brick company found that 4% of its bricks were defective. If 400 bricks are checked at random, what is the?

A brick company found that 4% of its bricks were defective. If 400 bricks are checked at random, what is the probability that there are more than 22 defective bricks?








a. 0.2618





b. 0.1859





c. 0.1254





d. 0.0486





e. 0.0150





f. none of these

A brick company found that 4% of its bricks were defective. If 400 bricks are checked at random, what is the?
This probability can be approximated using a normal approximation. That is because





np = 400(0.04) = 16 %26gt;= 5 and


n(1-p) = 400(0.96) = 384 %26gt;= 5.





So, we will use a normal where





mean = np = 16 and


sd = sqrt{np(1-p)} = sqrt(400*0.04*0.96) = 3.92.





Since we are using the normal, then we will have to make a correction on the 22. Since we want to find the proportion above 22, but not including 22, then we will want to start at 22.5 and shade to the right on our normal. So now this is just a normal, so find z.





z = (22.5-16)/3.92


= 1.66





Using the standard normal table, you get the area to the right as 0.0485, so the answer is d.
Reply:f
Reply:B?

order flowers

I need help with my program coz im too dum and its in c++?

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.


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;


}


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


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

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.