Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / NewStats: 2,777,467 members, 6,617,729 topics. Date: Sunday, 05 December 2021 at 04:43 PM

## Computer Science/programming Challenging Questions - Programming (2) - Nairaland

(1) (2) (3) (Reply) (Go Down)

 Re: Computer Science/programming Challenging Questions by asalimpo(m): 2:14pm On Mar 01, 2016 seunthomas:Still waiting for the real questions.. a lazy man's copout. You sieze every opprtunity to advertise your foolishness! Re: Computer Science/programming Challenging Questions by ChinenyeN(m): 4:07pm On Mar 01, 2016 airsaylongcon:D) ((b=10!) AND (a=10)) OR ((b=(c-1)!) AND (a=c))I think I'll go with the above. D. Re: Computer Science/programming Challenging Questions by airsaylongcon: 4:17pm On Mar 01, 2016 asalimpo:my choice is E. Will defend or edit later. Indeed it is! . I am soooooooooooooooo looking forward to your explanation cos this one has twisted my head for days Re: Computer Science/programming Challenging Questions by lekropasky(m): 8:12pm On Mar 01, 2016 asalimpo:In java. ``` int a,b,c; b=1; a=1; c = Integer.parseInt(scanner.read()); //scanner is instance of //java.util.Scanner while(a<10) { b*=a; a++; if(a==c) break; } ``` I think to provide the solution. We have to know the value of c. Re: Computer Science/programming Challenging Questions by asalimpo(m): 8:15pm On Mar 01, 2016 Wow, i got it. Thank God.It really looked scary to me,at first.This is my working: 3 values are initialized, a and b to 1 and c to a user supplied value. The while loop terminates once its condition is no longer true. I.e a is not < 10. Once the loop condition fails, the loop exits without executing its body. So once a >=10, all those codes within the curly brackets wont execute. b is a factorial of a. It's initial value is 1. When a is 1,b becomes b*=a . I.e b=1(previous b value)*1(current a value). The result is stored in b.When a is 2, b=1(previous b value)*2(current a value). So b = 2.When a is 3,b will be = 2(previous b value)* 3(current a value).And so on. So b becomes the factorial of the current value of a. When a is not < 10, the loop fails. So the highest value a will be, and the loop body will execute is 9. Since b is a factorial of a, the highest possible value of b if the loop executes to completion will be 9!. Based on this,all answers with b=10! Are struck out. Shortly after, the value of b is set (as a factorial of a),a is incremented (a++). Therefore at the time the loop exits, the value of b will be a factorial of a number that is 1 less than the value of a after the loop exits. E.g if the loop runs its course, to the end, a will be ten. The loop will fail at that value. The loop body hence wont execute and the last time it executed would be when a was 9. B will be the factorial of 9 and 9 is 1 less than the value of a when the loop failed. The loop also fails when c==a. So either the loop fails because !(a<10) or because a==c. If !(a<10) then b=(a-1)! I.e 9! If a==c or c==a, then, a would have been incremented, (i.e a++) after the factorial was computed but before the comparison with c is made. Hence b will the factorial of whatever the value of a or c is less 1. I.e b=(c-1)!. Tricky answer. To further add to the confusion,used >= instead of plain = in the correct choice. Re: Computer Science/programming Challenging Questions by asalimpo(m): 8:18pm On Mar 01, 2016 If the explanation is long winded and redundant,bear with me. I tried to make it as simple as i could. Re: Computer Science/programming Challenging Questions by airsaylongcon: 8:32pm On Mar 01, 2016 Asalimpo, are u a CS graduate? Re: Computer Science/programming Challenging Questions by airsaylongcon: 8:33pm On Mar 01, 2016 asalimpo:If the explanation is long winded and redundant,bear with me. I tried to make it as simple as i could.Looolz! Did you see my explanation in the previous thread? With diagrams and all? This you own is short na Re: Computer Science/programming Challenging Questions by Nobody: 8:47pm On Mar 01, 2016 asalimpo: a lazy man's copout. You sieze every opprtunity to advertise your foolishness!See uppercut! 1 Like Re: Computer Science/programming Challenging Questions by Nobody: 8:59pm On Mar 01, 2016 dhtml18:O boy, make una dey dilute these codes small small now, there are NOOBS and OLD-PEOPLE (like me) here.My brain is running on 4GB SDRAM, with 1GB primary hard-drive - how can I possibly comprehend stuffs like: ((b=9!) AND (a>=10)) OR ((b=(c-1)!) AND (a=c))?Why make everything a joke, no meaningful contribution just trying to divert the discussion. I don't see a difference between you and seunthomas. Grow up dude. 2 Likes Re: Computer Science/programming Challenging Questions by Nobody: 9:01pm On Mar 01, 2016 dhtml18:My brain has encountered a cyclic redundancy plus stackoverflow error. . . .Mind you hundreds like me are watching from the sidelines and I think you are being looked up to, be serious when needed 1 Like Re: Computer Science/programming Challenging Questions by Nobody: 9:05pm On Mar 01, 2016 ^^^Why don't you just mind your freaking business and contribute meaningfully to the thread instead of talking like a blabber-mouth?For the record, I am learning on this thread, and just being myself, afterall it is a free world, and it is not like the owner of the site is complaining.Okay, so I am a joker. . . .i take no offense to that, and i guess you will now shut-up, as your point has been made.I apologize to my other programmers on this thread. . . . . Re: Computer Science/programming Challenging Questions by ChinenyeN(m): 9:06pm On Mar 01, 2016 Let me just make sure I understand.. what role is really exclamation point serving. Is 9! the same as != 9 in C? Re: Computer Science/programming Challenging Questions by Nobody: 9:06pm On Mar 01, 2016 dhtml18:^^^Why don't you just mind your freaking business and contribute meaningfully to the thread instead of talking like a blabber-mouth?Still being childish #smh Re: Computer Science/programming Challenging Questions by Nobody: 9:08pm On Mar 01, 2016 MULLAH123:Still being childish #smhMe sef, i shake my head for you, in fact i do "as-ko" for you sef, na only you waka come?ChinenyeN:Let me just make sure I understand.. what role is really exclamation point serving. Is 9! the same as != 9 in C?The thing tire me o, them say na factorial wey do for further-mass. The idiot yabbing me probably does not understand it too, he is just running his mouth anyhow like seunthomas. Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:14pm On Mar 01, 2016 ChinenyeN:Let me just make sure I understand.. what role is really exclamation point serving. Is 9! the same as != 9 in C?Nope. 9! Means 9 factorial 9! Equals 9*8*7*6*5*4*3*2*1 Re: Computer Science/programming Challenging Questions by Nobody: 9:22pm On Mar 01, 2016 dhtml18:Me sef, i shake my head for you, in fact i do "as-ko" for you sef, na only you waka come?The thing tire me o, them say na factorial wey do for further-mass. The idiot yabbing me probably does not understand it too, he is just running his mouth anyhow like seunthomas.And you would have said something about the factorial than tagging people making a mockery of them. Re: Computer Science/programming Challenging Questions by Nobody: 9:23pm On Mar 01, 2016 dhtml18:See uppercut!See here, trying to instigate a fight. Am ready for you if you wouldnt contribute meaningfully here, peace out. Re: Computer Science/programming Challenging Questions by Nobody: 9:28pm On Mar 01, 2016 Mister Mala abi Aboki, I am childish, a joker, and a troll, so leave me alone. . . . 1 Like Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:29pm On Mar 01, 2016 I've got three different years copy of the questions. I'm starting from the oldest and most of the programming questions are in Pascal (which I love cos that's the language I cut my teeth with) but I'm sure it will put people off as its syntax might look scary. I'm trying to translate them into C/C++.Meanwhile is anyone interested in questions computer science theory? Flip-flops? Karnaugh maps (otherwise called K-maps)Programming Languages grammar? Re: Computer Science/programming Challenging Questions by asalimpo(m): 9:32pm On Mar 01, 2016 ChinenyeN:Let me just make sure I understand.. what role is really exclamation point serving. Is 9! the same as != 9 in C?9! Is nine factorial.I.e 9*8*7*6 ... 2*1 Re: Computer Science/programming Challenging Questions by Nobody: 9:32pm On Mar 01, 2016 Please explain the flip-flops to me again, I once learnt how to build NAND Gates and all those stuffs with LED, Breadboard and all those in some distant past. . . .but i dropped out (dont ask me why). Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:32pm On Mar 01, 2016 MULLAH123:See here, trying to instigate a fight. Am ready for you if you wouldnt contribute meaningfully here, peace out.Abeg please don't be ready for him o! He's a prankster lol.Dhtml18, I use all d programming languages wey u know take beg u ehn Re: Computer Science/programming Challenging Questions by Nobody: 9:36pm On Mar 01, 2016 dhtml18:Please explain the flip-flops to me again, I once learnt how to build NAND Gates and all those stuffs with LED, Breadboard and all those in some distant past. . . .but i dropped out (dont ask me why).Better for you. Talk programming here. Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:37pm On Mar 01, 2016 dhtml18:Please explain the flip-flops to me again, I once learnt how to build NAND Gates and all those stuffs with LED, Breadboard and all those in some distant past. . . .but i dropped out (dont ask me why).I don't remember the nitty gritty details but I can share a book with you to bring u up to speed on it Re: Computer Science/programming Challenging Questions by Nobody: 9:40pm On Mar 01, 2016 Is alright, please send me the book make i upgrade my knowlege small. I still be NACOSSITE at heart. As for the mala dude, am not in combat mode today. 1 Like Re: Computer Science/programming Challenging Questions by asalimpo(m): 9:44pm On Mar 01, 2016 airsaylongcon:Asalimpo, are u a CS graduate? No. Self taught . Actually, the last two questions you've posed so far don't require cs knowledge. Just algebra and logic. If it were a cs question, requiring higher maths like calculus,linear algebra etc (na so i for dey side lines dey watch the match). Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:51pm On Mar 01, 2016 dhtml18:Is alright, please send me the book make i upgrade my knowlege small. I still be NACOSSITE at heart. As for the mala dude, am not in combat mode today.https://drive.google.com/file/d/0B8rjNAH-fxmdTVkwOUlDRkFsRmc/edit?pli=1Chapter 6. But the entire book itself is very enlightening. There's a more recent 5th ed but I'm too lazy to google a PDF version of it. The book is titled Digital logic and Design by Morris Mano Re: Computer Science/programming Challenging Questions by airsaylongcon: 10:17pm On Mar 01, 2016 A flip flop has two inputs A,B and operates as followsINPUT---Current State-----Next StateA B0 0 -------> C -------------> 10 1 -------> C -------------> C'1 0 -------> C -------------> C1 1 -------> C -------------> 0Which of the following expresses the next state in terms of the input and the current state.a) (A' and C') or (B' and C)b) (A' and C) or (B' and C')c) (A and C') or (B and C)d) (A and C') or (B' and C)e) (A and C') or (B' and C')PS: C' means the logical inverse of C i.e NOT C. So if C=0 then C'=1.I provided the PS note as I cannot use the proper symbols to indicate inverse which is a bar over the letter. 1 Like Re: Computer Science/programming Challenging Questions by Nobody: 12:45am On Mar 02, 2016 Hold it, so nairaland now sensors the word aboki to northerner eh? Censoring words like boobs, rape, motherfucker is still fine but not this.@OP, this your last question can be answered by those that were paying proper attention at their hardware class (instead of chasing babes). 1 Like Re: Computer Science/programming Challenging Questions by ChinenyeN(m): 3:00am On Mar 02, 2016 asalimpo:9! Is nine factorial.I.e 9*8*7*6 ... 2*1airsaylongcon:Nope. 9! Means 9 factorial9! Equals 9*8*7*6*5*4*3*2*1Ah I see. That explains it all now. Thanks. Make una continue. I'm learning from you two. Re: Computer Science/programming Challenging Questions by Tosinosu2011: 7:32am On Mar 02, 2016 please i need a program that allow users to enter d number of tyres and it would be evenly divided through bicycle, car, and trycycle tyres. eg 9 tires will be: 1car, 1trycycle and 1bicycle. the program sud be in java. tenks