create a program to produce a tableof cosines for given angles. Note that the program is to read an input file and write outputto an output file. You should prepare many input files and an input file that includes a negative number and a value
between 90o and 180o among the input values.

this just really confused me, does anyone know what to do?

8 Years
Discussion Span
Last Post by Ancient Dragon

>>does anyone know what to do?
Yes, don't you ?

Use the cos() function in math.h to calculate the cosignes of the numbers read from the data file.

You first have to create the input file(s) probably using Notepad.exe or some other standard text editor from the operating system you are using.


math.h? is that the same as cmath? bc that's all i've ever used.


how do you do an array when you don't know how many will be put into it?


This is c++ so use std::vector class. Its an array that auto expands to hold however may items you want to put into it.

#include <vector>
using std::vector

int main()
    vector<int> ary;
    // add an int to the array
   // add another integer
   int number = 234;


But I don't see a requirement for you to put all the numbers in an array. Just store them in a data file and be able to read them back. The instructions you posted say nothing about how the numbers are to be stored when read back. Maybe all you have to do is print them on the screen as they are read from the file. In that case they don't have to be stored anywhere.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.