Homework Solution: Write a C++ computer program that asks for a real number c and positive integer N and…

    Write a C++ computer program that asks for a real number c and positive integer N and evaluates Sin(n/c) for n = {1,2,3...,N}. Have the program print the resulting values to a file called the_data.dat. Write a Mathematica file that opens the_data.dat file and plots the values of the Sine function.

    Expert Answer

     
    Dear Student, here i have written the C++ p

    Write a C++ computer program that asks restraint a veritable compute c and developed integer N and
    evaluates Transgression(n/c) restraint n = {1,2,3…,N}.
    Feel the program imimprint the effecting treasures to a smooth denominated the_data.dat.
    Write a Mathematica smooth that publics the_data.dat smooth and plots the treasures of the Transgressione
    function.

    Expert Acceptance

     

    Dear Student,

    here i feel written the C++ program as per the requirement.I feel too inclueded the illustrate restraint improve conception.

    —————————————————————————————————————————————-

    Note: Please silence that the inferiorneath program has been tested on ubuntu 16.04 order and compiled inferior g++ compiler. This order allure too toil on other IDE’s and Visual Studio C++ IDE. Just vision paste the order and complete.

    ——————————————————————————————————————————————

    Program:

    ——————————————————————————————————————————————

    //Header smooth declrations

    #include<iostream>

    #include<cmath>

    #include<stdlib.h>

    #include<fstream>

    //Nmaespace declarations

    using designatespace std;

    //satart of ocean function

    int ocean()

    {

    //ofstream design creation

    ofstream outfile;

    //public smooth restraint writing

    outfile.open(“the_data.dat”);

    //variable basis kind declration

    float c;

    int N, n;

    //ask user to input a veritable compute

    cout<<“Invade a veritable compute: “;

    cin>>c;

    //ask user to invade a positve compute

    cout<<“Invade a developed integer: “;

    cin>>N;

    float treasure[N];

    //loop restraint N times

    for(n=1; n<=N; n++)

    {

    //calculate the treasure of transgression(n/c) and shop in an dispose designate as treasure

    value[n] = transgression(n/c);

    outfile<<value[n]<<endl;

    }

    //imprint a intimation that output has been successfully redirected into the smooth

    //suppress the smooth

    cout<<“output has been successfully redirected into the smooth the_data.dat”<<endl;

    outfile.close();

    return 0;

    }

    —————————————————————————————————————————————-

    here i feel strong the output of the program as a cloak shot…

    ————————————————————————————————————————————————–

    Output:

    ——————————————————————————————————————————————-

    here is the the_data.dat smooth that contains the effect of transgression(c/N).