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?

Recommended Answers

All 5 Replies

>>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.

yes, they are the same (probably)

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
    ary.push_back(1234);
   // add another integer
   int number = 234;
   ay.push_back(number);

}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.