![]() |
|
[C] Need to create a simple program for homework - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] Need to create a simple program for homework (/showthread.php?tid=5902303) |
Need to create a simple program for homework - Voxi - Nov 1, 2018 Here is what I have to do: You know that the combination to a safe is a four-digit integer (between 1000 and 9999) that: a) is a perfect square, and b) is not divisible by 2, 3 or 5. Could anyone help me out on where i'd start? I'm really bad at C++ and think i'm gonna fail my class lol RE: Need to create a simple program for homework - Mouse❤️ - Nov 1, 2018 If that's your assignment, I see why you're failing. There aren't even any instructions. It's just telling you what an incorrect definition of a number combination is. RE: Need to create a simple program for homework - Souffrance - Nov 1, 2018 Assuming you have to code it, the way I would start is by having a loop that goes from: 32 till 99. In each of these iterations of the loop, get the squared number (i.e. number times itself, then check if it's divisible by 2, 3 or 5.) If it isn't divisible by any of them. Print it out. Of course that's just assuming this is what the assignment actually wants you to do. You'll need to use a for loop and an if statement to accomplish this. RE: Need to create a simple program for homework - int main() - Nov 2, 2018 (Nov 1, 2018 03:55 PM)Mouse❤️ Wrote: If that's your assignment, I see why you're failing. There aren't even any instructions. It's just telling you what an incorrect definition of a number combination is. LOOOOOOOOOL poor guy RE: Need to create a simple program for homework - FoxBlood - Nov 2, 2018 Nobody will help you here, it's about your programming education, if you don't like programming that means you are in a wrong school RE: Need to create a simple program for homework - Abruptum - Nov 2, 2018 Hey, The Solution is quite easy to understand. Code #include <math.h>Do it now yourself, use stackoverflow and other sites to gain informations how other people have solved this problem. (There is a better version and you should be able to create it now on your own) RE: Need to create a simple program for homework - Souffrance - Nov 2, 2018 (Nov 2, 2018 08:37 AM)Abruptum Wrote: Hey, This is inefficient, I'm not sure why you're checking if each number is a perfect square at all. Just generate only perfect squares instead. RE: Need to create a simple program for homework - icko1996 - Nov 2, 2018 Don't forget about the modulus operator. You can check if a number is divisible by another number the following way: ( x % y ) == 0, where x is the dividend, y the divisor. Good luck with your assignment! RE: Need to create a simple program for homework - Abruptum - Nov 2, 2018 (Nov 2, 2018 12:21 PM)Souffrance Wrote: This is inefficient, I'm not sure why you're checking if each number is a perfect square at all. Just generate only perfect squares instead. OMG ;D it was just an bad example so he could improve it. Pleas read the whole post and don't bitch around. RE: Need to create a simple program for homework - incognito04 - Nov 14, 2018 A short example program 🤝. PHP Code RE: Need to create a simple program for homework - kray - Nov 15, 2018 (Nov 1, 2018 03:55 PM)Mouse❤️ Wrote: If that's your assignment, I see why you're failing. There aren't even any instructions. It's just telling you what an incorrect definition of a number combination is. after first reading the original post, I was confused. After reading your reply, I laughed so hard I'm now dead. |