K
kupiko
Please can anyone help me on this code? I want
to write all odd numbers in range from a to b but it doesn't work at all
cases mainly when a is higher than b and when i type in negative numbers.
Here is the code and i would appreciate anybody helping me. THANKS.
#include<stdio.h>
#include<math.h>
void odd(float x, float y);
void change(float x, float y);
void odd(float x, float y)
{
int i;
if (x>y) change(x,y);
x=roundf(x);
y=roundf(y);
for(i=1;i<(y-x)+1;i++)
if ( fmodf ((x+i),2)==1 || fmodf ((x+i),2)==-1 ) printf( "%f
",(x+i) );
}
void change(float x, float y)
{
float c;
c=x;
x=y;
y=c;
}
main()
{
float a,b;
printf("Type two real numbers :");
scanf("%f%f",&a,&b);
odd(a,b);
getchar();
getchar();
}
to write all odd numbers in range from a to b but it doesn't work at all
cases mainly when a is higher than b and when i type in negative numbers.
Here is the code and i would appreciate anybody helping me. THANKS.
#include<stdio.h>
#include<math.h>
void odd(float x, float y);
void change(float x, float y);
void odd(float x, float y)
{
int i;
if (x>y) change(x,y);
x=roundf(x);
y=roundf(y);
for(i=1;i<(y-x)+1;i++)
if ( fmodf ((x+i),2)==1 || fmodf ((x+i),2)==-1 ) printf( "%f
",(x+i) );
}
void change(float x, float y)
{
float c;
c=x;
x=y;
y=c;
}
main()
{
float a,b;
printf("Type two real numbers :");
scanf("%f%f",&a,&b);
odd(a,b);
getchar();
getchar();
}