- #1
jasonsmith206
- 10
- 0
Hi everyone, been a busy week and I've got midterm cal 2 on monday so i need to get this done as fast as possible so i can focus on my math.
I've got two assignments each requiring me to input 819877966 as a user number and its two parts
1.) is to break the usernumber into individual numbers and tell if they are odd or even
example:
n odd/even
-- ---------
8 even
1 odd
9 odd
. ...
. ...
the code i have for that so far is this:
I can get it to break up but i can't figure out how or where for my program to read odd/even.
2.)
the same usernumber will be used to read prime numbers so
if it was to read
819877966
it would out put certain numbers saying what its divisable
example:
81 wouldn't be a prime number and would be broke up to its facortrization until it reaches a prime number.
I hate these exerecises because we are only a month into our programming class and our teacher gives us problems like these. Idk what he's thinking but these kinds of questiosn are crazy for first time programmers so any help given will be greatly appreciated!
Thank you
I've got two assignments each requiring me to input 819877966 as a user number and its two parts
1.) is to break the usernumber into individual numbers and tell if they are odd or even
example:
n odd/even
-- ---------
8 even
1 odd
9 odd
. ...
. ...
the code i have for that so far is this:
Code:
#include<stdio.h>
int main()
{
int num,temp,factor=1;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while(temp){
temp=temp/10;
factor = factor*10;
}
printf("Each digits of given number are:\n");
while(factor>1){
factor = factor/10;
printf("%d\n",num/factor);
num = num % factor;
}
return 0;
}
I can get it to break up but i can't figure out how or where for my program to read odd/even.
2.)
the same usernumber will be used to read prime numbers so
if it was to read
819877966
it would out put certain numbers saying what its divisable
example:
81 wouldn't be a prime number and would be broke up to its facortrization until it reaches a prime number.
I hate these exerecises because we are only a month into our programming class and our teacher gives us problems like these. Idk what he's thinking but these kinds of questiosn are crazy for first time programmers so any help given will be greatly appreciated!
Thank you
Last edited by a moderator: