Okay so the object is to print a wheel based on the user's input of the inner and outer radii. I've written a program that checks to see if the distance of the x and y is within the radius. However, i get some weird stretched out tire. If anyone could tell me what i'm doing wrong I would greatly appreciate it.
Here is my code:
#include <stdio.h>
int main (void){
int outer, inner, y,x;
printf("What is the outter radius of your tire?\n");
scanf("%d", &outer);
printf("What is the inner radius of your tire?\n");
scanf("%d", &inner);
for(x=-outer; x<=outer; x++){//sets row = -bigradius and increments all the way to +bigradius
for(y=-outer; y<=outer; y++){//sets columns = -bigradius and increments all the way to +bigradius
if((x*x)+(y*y)<=1)//Tests if the radial distance is less than 1. If so print a +.
printf("+");
else if((x*x)+(y*y)<=(inner*inner))//Test if the radial distance is less than or equal to the inner radius. If so print a $.
printf("$");
else if((x*x)+(y*y)<=(outer*outer))//Tests if radial distance is less or equal to outer radius. If so prints a *.
printf("*");
else if((x*x)+(y*y)>=(outer*outer))//Checks to see if the distance is greater than the outer radius. If so goes to new line.
printf("\n");
}
}
return 0;
}
And the out out i get from this is:
What is the outter radius of your tire?
14
What is the inner radius of your tire?
10
*
***********
***************
*****************
*********$*********
******$$$$$$$$$******
*****$$$$$$$$$$$$$*****
*****$$$$$$$$$$$$$$$*****
****$$$$$$$$$$$$$$$$$****
*****$$$$$$$$$$$$$$$$$*****
****$$$$$$$$$$$$$$$$$$$****
****$$$$$$$$$$$$$$$$$$$****
****$$$$$$$$$$$$$$$$$$$****
****$$$$$$$$$+$$$$$$$$$****
****$$$$$$$$$+++$$$$$$$$$****
****$$$$$$$$$+$$$$$$$$$****
****$$$$$$$$$$$$$$$$$$$****
****$$$$$$$$$$$$$$$$$$$****
****$$$$$$$$$$$$$$$$$$$****
*****$$$$$$$$$$$$$$$$$*****
****$$$$$$$$$$$$$$$$$****
*****$$$$$$$$$$$$$$$*****
*****$$$$$$$$$$$$$*****
******$$$$$$$$$******
*********$*********
*****************
***************
***********
*