So I'm working on two questions while learning C.(adsbygoogle = window.adsbygoogle || []).push({});

The first question is, I need to create a program that prompts a user "Please enter an integer" and display whether the answer is odd or even. I'm using the logic that you can divide the input by 2, if the answer is a whole number it is even, if it's a decimal it is odd. How can you check whether the input is a decimal or not? Would this solution work for a question that asked for an input of 2 numbers, say "15 5"? Let 15 be a, 5 be b and divide a by b; if answer is whole number then it is a multiple, else it is an odd number?

Second question is, I need to create a program that prompts a user "Please enter a five integers:" for example "5 12 -10 0 1". From there it will display "The max is: 12" and "The min is -10". How can I do this without using an array?

I get the idea behind it, I just can't figure out how to make it check whether the output of the calculation is a float. Additionally, this is an intro to learning C class; my idea for a solution to question 1 was using something like "scanf("%d", a b c d e); and then a long line of code checking if each variable is greater than eachother. This obviously didn't seem very efficient to me is there another basic way I can try?

Thanks!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Basic C Program - Help with logic!

Loading...

Similar Threads for Basic Program Help |
---|

Insights Intro to Algorithms for Programming - Comments |

C/++/# Ideas for a physics or math programming project? |

Program that calculates the list of x and f(x) for a given function |

Using Visual Basic |

Anyone know any good basic hacking books? |

**Physics Forums | Science Articles, Homework Help, Discussion**