TotalView C Serial Exercise 1 - Assignment

Assignment

To your left you can select to see more details on this assignment if you need them. You can also select tips if you need some suggestions to get started on the assignment. Finally, you can select Solution to view a solution to the problem.

Your first assignment is to use TotalView to locate an error in the following program. The program is printing a value of "NAN" or "-Infinity" for one of the values. Compile the code with ifort and locate the source of the error.

#include <stdio.h>
#include <math.h>
int main()
{
     float vec[10];
     int i;
     for (i=1;i<10;i++){
       vec[i]=2.0*(i+1);
     }
     for (i=0;i<10;i++){
       vec[i]=log(vec[i]);
     }
     for (i=0;i<10;i++){
       printf("%f
",vec[i]);
     }
     return 0;
}