Commit fc215fc3 by viakul

Update Homework_2.c

parent 433089c7
Showing with 14 additions and 9 deletions
...@@ -171,13 +171,6 @@ void tracePrint(char arr1[15][20], int n){ ...@@ -171,13 +171,6 @@ void tracePrint(char arr1[15][20], int n){
/*function input:
* empty arrays of distances and names of traces,
* values for distances, number of traces;
* Since it is requred to know n traces and n distances
* the code reads the user input 2n times
*/
void filling_array(char arr[15][20],char arr1[15][20],float val[15],int n){ void filling_array(char arr[15][20],char arr1[15][20],float val[15],int n){
int i, y, j; int i, y, j;
//use the variable to keep track of different elements inside arrays //use the variable to keep track of different elements inside arrays
...@@ -198,12 +191,24 @@ void tracePrint(char arr1[15][20], int n){ ...@@ -198,12 +191,24 @@ void tracePrint(char arr1[15][20], int n){
else else
{ {
printf("Write the distance #%d:\n", y + 1); printf("Write the distance #%d:\n", y + 1);
scanf("%s", arr1[y]); while(1)
val[y] = atof(arr1[y]); {
scanf("%s",arr1[y]);
val[y]=atof(arr1[y]);
//atof converts the string to a float //atof converts the string to a float
if(val[y]>0)
{
y++; y++;
break;
}
else
{
printf("Please write the valid expression for the length it should be positive\n");
} }
} }
}
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment