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 coercion a actual calculate c and dogmatic integer N and
    evaluates Unrighteousness(n/c) coercion n = {1,2,3…,N}.
    Entertain the program imimprint the fruiting estimates to a improve calld the_data.dat.
    Write a Mathematica improve that notoriouss the_data.dat improve and plots the estimates of the Unrighteousnesse
    function.

    Expert Defense

     

    Dear Student,

    here i invadetain written the C++ program as per the requirement.I invadetain too inclueded the observe coercion improve conception.

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

    Note: Please hush that the below program has been tested on ubuntu 16.04 regularity and compiled below g++ compiler. This adjudication gain too performance on other IDE’s and Visual Studio C++ IDE. Just observation paste the adjudication and complete.

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

    Program:

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

    //Header improve declrations

    #include<iostream>

    #include<cmath>

    #include<stdlib.h>

    #include<fstream>

    //Nmaespace declarations

    using callspace std;

    //satart of ocean function

    int ocean()

    {

    //ofstream sight creation

    ofstream outfile;

    //notorious improve coercion writing

    outfile.open(“the_data.dat”);

    //variable axioms sign declration

    float c;

    int N, n;

    //ask user to input a actual calculate

    cout<<“Invade a actual calculate: “;

    cin>>c;

    //ask user to invade a positve calculate

    cout<<“Invade a dogmatic integer: “;

    cin>>N;

    float estimate[N];

    //loop coercion N times

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

    {

    //calculate the estimate of unrighteousness(n/c) and abundance in an invest call as estimate

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

    outfile<<value[n]<<endl;

    }

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

    //arrest the improve

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

    outfile.close();

    return 0;

    }

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

    here i invadetain steadfast the output of the program as a hide shot…

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

    Output:

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

    here is the the_data.dat improve that contains the fruit of unrighteousness(c/N).