Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   the program should include "c" language not "c++' (http://www.go4expert.com/forums/program-include-c-language-cpp-t27001/)

i_s_a_a_c 23Oct2011 19:52

the program should include "c" language not "c++'
 
I want to write a program in c that will get real values for the length of three sides of a triangle in ascending order and determine the nature of it.



ANOTHE PROGRAM:
I whant to WRITE A PROGRAM to print the ASCII table from 0x20 (spaces) to 0x7f (DEL) which is an unprintable character


ANOTHER PROGRAM:
i want to erite a program to test the knowlege of a child in single-digit multiplication. the program must initially promot the child the number of exercise he\she desires to do. each exercise displays the questions in form a*b=? where a and b are single-gigits numbers (0-9) chosen randomly using the functions srand() and rand(). for each answer the program displays "true" or "false" . upon termination the program displays the test score.



PLZ HELPE ME AND THANK YOU:):):)

xpi0t0s 24Oct2011 02:19

Re: the program should include "c" language not "c++'
 
Easy enough. How far have you got and where are you stuck?

The second one is particularly easy - can be done in just 2 lines of code, however you need to decide how you want to represent an unprintable character. Any thoughts on that? Do you know about the isprint() function?

Third one a bit more tricky but again not that hard. Where are you stuck?

i_s_a_a_c 24Oct2011 17:03

Re: the program should include "c" language not "c++'
 
man i am new to this & i was not abel to know from were i could start so plz help me:):)

xpi0t0s 24Oct2011 18:55

Re: the program should include "c" language not "c++'
 
Best bet is to go on a programming course, or get tuition off someone you know. It's not easy to teach C in a forum like this. Failing both of those, you could try reading a C book; there is lots of choice.

i_s_a_a_c 24Oct2011 21:42

Re: the program should include "c" language not "c++'
 
but can u plz tell me how to solve these three programs :):)

xpi0t0s 24Oct2011 21:52

Re: the program should include "c" language not "c++'
 
No. Programming is all about doing stuff yourself. Go and learn the language, and you'll be surprised how soon you can in fact do these three tasks (within a month, if you work hard).

i_s_a_a_c 25Oct2011 00:34

Re: the program should include "c" language not "c++'
 
i know what u mean but i have these as a homework for next week & i spent houres & i made many research and i was not abel to solve it:(:( so plz help me cz its graded

xpi0t0s 25Oct2011 03:07

Re: the program should include "c" language not "c++'
 
OK, so how far did you get, and where did you get stuck? If you've spent hours on them you must have *something* to show for it. Even if you didn't get the code working properly, you must have something we can start with.

i_s_a_a_c 25Oct2011 11:02

Re: the program should include "c" language not "c++'
 
in the 1st one i know how tocontinue but i just don't know how to make the programe take the values in ascending order
the second one i have solvet by using only printF
and the 3rd i didn't know how to start cz i did not know how to make the program shoose 5 random questiond

xpi0t0s 25Oct2011 19:53

Re: the program should include "c" language not "c++'
 
>> in the 1st one i know how tocontinue but i just don't know how to make the programe take the values in ascending order

Given the problem description I don't think you need to: just input the numbers in increasing order, for example
Enter length 1: 5
Enter length 2: 7
Enter length 3: 9

But if you need to be able to handle non-increasing order, e.g.
Enter length 1: 9
Enter length 2: 5
Enter length 3: 7

you could swap them around with comparisons. A three-way swap is not difficult to figure out. If a>b then the largest is whichever is larger of a and c, and the smallest is whichever is the smaller of b and c. The middle value is the one that's left.

>> the second one i have solvet by using only printF

Great, well done! See, it's not that difficult when you start working on it, the trick is not to be overawed by the amount of work placed in front of you, just break it down and take it one step at a time.

>> and the 3rd i didn't know how to start cz i did not know how to make the program shoose 5 random questiond

Easiest way is to figure out how to make the program choose one random question, then to put that in a (for i=0; i<5; i++) loop. But the question itself tells you a lot:

- the program must initially promot the child the number of exercise he\she desires to do

I guess here "promot" means something like ask. So that means using cin or scanf as you've been shown. Store that value somewhere and use it in a loop's terminating expression.

- each exercise displays the questions in form a*b=? where a and b are single-gigits numbers (0-9) chosen randomly using the functions srand() and rand()

I don't know what a gigit is, digit perhaps? Anyway, do you know how to get a number from 0-9 using srand() and rand()? You're unlikely to be asked this without any background, so check through your course notes and you should find it with some examples, and you may even be lucky enough to have an example that shows how to get a single-digit random number. Do that twice and store the results into variables named a and b.

- for each answer the program displays "true" or "false"

OK so that means you need to get the answer from the user, and calculate the answer yourself, and compare the two results. You already know how to get input, and you should be able to figure out how to calculate the answer, so get both of those into separate variables and use the == operator, and display "true" or "false" accordingly.

- upon termination the program displays the test score.

This means you'll need some way of counting the number of correct answers. So you could think up a new variable name, initialise it to zero at the start of the program, then increment it each time you print "true".


All times are GMT +5.5. The time now is 22:45.