Commit fc215fc3 by viakul

Update Homework_2.c

parent 433089c7
Showing with 18 additions and 13 deletions
......@@ -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){
int i, y, j;
//use the variable to keep track of different elements inside arrays
......@@ -198,12 +191,24 @@ void tracePrint(char arr1[15][20], int n){
else
{
printf("Write the distance #%d:\n", y + 1);
scanf("%s", arr1[y]);
val[y] = atof(arr1[y]);
//atof converts the string to a float
y++;
}
}
while(1)
{
scanf("%s",arr1[y]);
val[y]=atof(arr1[y]);
//atof converts the string to a float
if(val[y]>0)
{
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