← Back to Kurakani

C Program help

Original Post

Hi all! Anybody done a C Program for "guessing a secret number"?

Robert Frost
Oct 17, 2004 5:09 PM · 12,122 views
34 Replies · Showing 21 - 34
Page 2 of 2
KALANKISTHAN Oct 18, 2004 1:52 PM
Echoes bruuu Aaaanch!! Guru is here... hehe... Bruuu, I gotta cut and paste above code for a future reference... hehe.... Wednesday I'm gonna post a project :P Deepak bru, are you up for it?? hehe.. don't worry, I have 20 days after this wednesday to submit it.... LOL.
Robert Frost Oct 18, 2004 6:05 PM
Echoes, I owe you one for that!!! I am thinking of a nice spanish cuisine or the finest of its cigar and champagne..!! Whaddya Sir?? :)
Rusty Oct 19, 2004 5:45 AM
Frosty, I think you better stick with coding poems.. :P Echoes, that's very good solution... really impressive
Echoes Oct 19, 2004 7:39 AM
Danny---haha. Well, lets hope that Bob doesn't turn in the screenshot jpegs, instead of the source and an executable! Just kidding. Umm...I do C# (not VB.NET) with .NET. But the paradigm is the same. So what's your question? You might want to check out the Microsoft Developer Netowrk (MSDN) www.msdn.microsoft.com, as well. Problems that are fun and won't take hours to solve are welcome. Kalanki---Sure, bro! Be warned though, it could be only to find out on the 20th day that it's still you who's going to have to do it! Robert---Sounds good. We'll have a toast after you've made it through the rest of the semester. Good luck to you. Rusty bru---ehehe. Well, looked like the kids were in trouble, so. But I feel good to have been complimented by a guru. Appreciated. Good day!
Robert Frost Oct 19, 2004 10:34 AM
Dear Rusty, How nice to hear from you....!! Why don't you start coding poems yourself, sunshine..!!! will join ya!! the pleasure will always be mine, as for now, I gotta take my time, to solve this pennies, nickels and dimes..!!!!!!!!!!!!! Echoes, Kalanki, Danny, and our Sajha programmers, help me please.!! Rewrite the program with functions to perform insert and remove operations. The function insert (int p, int n, int d, int q) will initialize pennies, nickels, dimes and quarters. The function dollars() will return the dollars. The function remove (int p, int n, int d, int q) will subtract pennies, nickels, dimes and quarters. The function display() returns a new String to print the content of the purse with remaining pennies, nickels, dimes and quarters. Make sure your program is working correctly. NB: I figure out not too long ago, that I am horrible in programming...!!!! :) I mean! I can do math problems, probably anything that makes sense and logics, but this programming, na!! man..!!
casey00 Oct 19, 2004 10:36 AM
Ok my question !! Has anyone made simplest of web browsers using JAVA? No features...just u give url and it runs!! I have to get that done in about a week and as usual very occupied with other subjects....anyone wanna give me some tips?
casey00 Oct 19, 2004 10:40 AM
"NB: I figure out not too long ago, that I am horrible in programming...!!!! :) I mean! I can do math problems, probably anything that makes sense and logics, but this programming, na!! man..!! "----RFrost -- I agree With you 100%. I have always been in Maths as well..I mean..I enjoy maths..but the hatest thing about programming is the errors it generates...and I dont have patience NOR do I LOVE programming lol.....I guess people who are really good in programming really LOVE what they are doing..I mean I have seen some people ..who enjoy being challenged with these kid of stuffs...amazing!!.
dananah Oct 19, 2004 2:44 PM
oi confused mula...are u that confused?:oP u gone over me expectations of u ;oP abo testo things pani sodney ho?hehe ....just mail it ke ;o)..abo gmail ke ko kaam?hehe.. look at those spammers....hyaaa esto bombard garda darda...urghhh.... anyways thanks ..esp oif it helps..i will treat u a cup of chia..if i ever get the chance la :o).. will find u in sajha now..since u might be there hehe...easier to pass it there hoina?trying to make it easier..hehe btw oi post ur desktop and make it less u know...make it more good for the eyes to see...wanna see if there is anything more useful u have for me ..turns out u r a useful bugger ;oP....hehe okkk good morn from here...cya in sajha..if u are there... echoes bro....hehe..i think robert will submit his poetry instead and impress the lecturer hehehe...and thanks for the site...gonna look at it when im in uni..cant do at home..need the bloody server...and C# hehe i think me frens needs ur help?when are u free?wanna setup a meeting with them?;oP... robert u like maths?urghh it kills me these days..:oS too long away from it :oS....programmin ta maths ni ho...freakn logics and syntax..its fun when it works..but if it doest..dyam!hehehe.....programming is practice too...if u love maths u will love it...dun u like to solve problems?hehe..mapani programming mah kharaab..:oS...dyam this reminds me..have to do me programming assing due last week!!arghhh!! good luck on urs...u better try to do it urself..and get some help hehe..unless if too urgent than let others do it fully for u hehe..cos well...we can 'lie' our way for a long time...but in the truth will be out...im sure u can do it..just try a bit harder..cos most prob...tho u think u tried hard enuf..maybe u aint?hehe :o)..ok enuf of lectures...im not that old..and that applies to me too...dyam i need to do me work!..have fun....programming..:o) laters danny
Robert Frost Oct 24, 2004 2:03 PM
Anybody please..I am still waiting on my program above...!
Robert Frost Oct 27, 2004 9:34 AM
Why is nobody listening to me???? SAJHA DEBUGGERS HELP WANTED>>>!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Here is the program and below I have listed the errors that I am not being able to fix...I need your help, just asked for the Prof. for more time on this project..so please help me.. #include int pennies, nickels, dimes, quarters; int main() { char y; int p,n,d,q; pennies=0; nickels=0; dimes=0; quarters=0; display(pennies,nickels,dimes,quarters); do { printf("Select an action:: (I/R/D/Q) \n"); printf("I = Insert, R = Remove, D = Display, Q = Quit"); scanf("%c", &y); if y = "I" { printf("Insert.."); scanf("%d%d%d%d", &p, &n, &d, &q); insert(p,n,d,q); display(pennies,nickels,dimes,quarters); } else if y = "R" { printf("Remove.."); scanf("%d%d%d%d", &p, &n, &d, &q); rem(p,n,d,q); display(pennies,nickels,dimes,quarters); } else if y = "D" { display(pennies,nickels,dimes,quarters); } while(y != "Q"); { printf("Program terminated..."); } } //Function that inserts money in the purse int insert(int p, int n, int d, int q) { pennies += p; nickels += n; dimes += d; quarters += q; } //Function that displays the contents of the purse int display(int pnys, int nkls,int dimes, int qrts) { float x = pnys + 5*nkls + 10*dimes + 25*qrts; x = (float)x/100; printf("Contents of your purse : \n"); printf( " %d quarters + %d dimes + %d nickels + %d pennies = $%d \n", qrts, dimes, nkls, pnys, x); } //Function that removes money from the purse int rem(int p,int n, int d,int q) { pennies -= p; nickels -= n; dimes -= d; quarters -= q; } Errors that are showing: pndq.c: In function `main': pndq.c:23: parse error before "y" pndq.c:30: parse error before "else" pndq.c: At top level: pndq.c:37: parse error before "else"
kalankisthan Oct 27, 2004 10:21 AM
RF, you are not comparing the characters in the if-else statement but you are assigning the value to y, which is wrong... you were supposed to compare... and also, put the ifstatement inside the bracket. Won't work if you don't. Try if(y == 'A'). I think it's supposed to be single quote, not the double quote. forgot.. :P Same with while loop, I guess, eh...
kalankisthan Oct 27, 2004 10:27 AM
and also your scanf("%c", &y); will run into problem coz it's in the while loop.... Works fine for the first loop, after that I am sure it will give you a problem. Think about this, you asked a user to enter a character... user enters a character... and hits the enterkey... so there is a newline also, which is \n, ie one character... so when the loop runs second time, it will read \n, and won't let a user to enter another character. There are bunch of ways to avoid this... one is use fflush(stdio); right after scanf. I think the other way is scanf(" %c", &something); NOTICE the space after " and %.
Echoes Oct 27, 2004 6:53 PM
Robert-- That was a good start. Good job! But start your assignments early, man! (Posting the problem statements on sajha isn't enough!) It'll be very rough to try to get a programming task done in the last minute. And be warned, these are trivial programs... the complexity will grow rapidly as the semester goes on... and it's easy to fall behind. When I used to be a TA, this used to be the single-most reason why many students failed: saving the programming assignments to the night before it's due. Just don't do it! Won't work in computer science. Well anyways. Sounds like you're in a desperate situation so I just spent an hour or so on it and here's the code. If it's for a school project, then please don't copy it as is. It's just so that you get an idea of how things can be done. As usual, Kalanki also has excellent suggestions for you... Hope it helps:
Echoes Oct 27, 2004 6:57 PM
And here's the program in action (read it in its entirety):
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant