Based on the material we have learned so far except for characters.
#include <stdio.h>
int Round2Int( float x);
#define PICK(start,stop) (rand() % ((stop) - (start) + 1) + (start))
void main(){
int ix, iy, x;
float fj, fk;
ix =3; iy = PICK(100,101);
printf("Please Enter Two Floats\n");
scanf("%f %f", &fj, &fk);
x = Round2Int(fk);
//x = x/iy;
printf("x = %d\n", x);
for(int i = 0; i < ix; i++){
printf("%d \t %d \n", i+1, x*=2);
}
printf("Program Ended\n");
return 1
}
int Round2Int(float x){
return (int)((x>0) ? x+0.5:x-0.5);
}
Trace This Program
// This a prototype for function round2int
//function like macro
//used to generate a random num
ix, iy, x are variables - ints
fj, fk are vars - floats