adds

Value of cosx by c ++:

CODING:           

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
void main()
{
    int i, n;
    float x, sum=1, t=1;
    clrscr();
    cout<<" Enter the value for x : ";
    cin>>x;
                                                         
    cout<<" Enter the value for n : ";
    cin>>n;
    x=x*3.14159/180;
     
    /* Loop to calculate the value of Cosine */
    for(i=1;i<=n;i++)
    {
        t=t*(-1)*x*x/(2*i*(2*i-1));
        sum=sum+t;
    }
     
    cout<<" The value of Cos("<<x<<") = "<<setprecision(4)<<sum;
    getch();
}
OUTPUT:



Model syllabus (+3)Downoad

List of all practicals:   Download

Get all Books:  Download
Physics Notes: CLICK

IIT-JAM             JEST                GATE               NET
                                                           
  • How to Prepare for IIT-JAM  ⇠ ⇠ Click Here
Get everything about your B.Sc (+3) Physics Practical⇠ ⇠Click
"The only reason for time is so that everything doesn't happen at once."  Albert Einstein

Post a Comment

Previous Post Next Post