Consider the following equations. š“ = 2š„ šµ = 2 cos š„ , š¤āššš š„ šš 10Ā° , 20Ā° , 30Ā° ā¦ 180Ā° š¶ = ā š + 5 5 100 š=0 Construct a C++ program to calculate and print out the value of A, B and C by considering the following conditions; 1- User must keyed-in āstartā and āstopā to control the program. 2- Use function to display all the above equations. 3- If user keyed-in āfunction1ā, calculate the value of A divided by C for the value of x from 1 to 100. 4- If user keyed-in āfunction1ā, calculate the value of B divided by A for the value of x from 2 to 200.
#include <cmath>
#include<dos.h>
#include <bits/stdc++.h>Ā
using namespace std;
/*
Consider the following equations. A = 2x,Ā
B = 2 Cos x, Cx = 10, 20, 30 , --- 180
C = Sum (n), n =Ā = ?? = 2?? ?? = 2 cos ?? , ??h?????? ?? ???? 10Ā° , 20Ā° , 30Ā° ā¦ 180Ā° ?? = ? ?? + 5 5 100 ??=0Ā
Construct a C++ program to calculate and print out the value of A, B and C by considering the following conditions;
1- User must keyed-in āstartā and āstopā to control the program.Ā
2- Use function to display all the above equations.Ā
3- If user keyed-in āfunction1ā, calculate the value of A divided by C for the value of x from 1 to 100.Ā
4- If user keyed-in āfunction1ā, calculate the value of B divided by A for the value of x from 2 to 200.
*/
void Display(void)
{
cout<<"\n\tFunction-1:\tA = 2x";
cout<<"\n\tFunction-2:\tB = 2 Cos (x)";
cout<<"\n\tFunction-3:\tC = Sum (n) + 55";
}
float Func_A(void)
{
float u=0;
for(float x=0;x<=180;x=x+10) u = u + 2*x;
return(u);
}
float Func_B(void)
{
float u=0;
for(float x=0;x<=180;x=x+10) u = u + 2*cos(x);
return(u);
}
float Func_C(float Start, float End)
{
float c=0;
for(float n=Start;n<=End;n++) c= c+n;
return(c);
}
int main()
{
int Flag=-1;
float x,A, B, C;
float Start=0,End=0,val;
while(Flag<0 || Flag>4)
{
cout<<"\n\tPress-1 to ebnter Start and End values:";
cout<<"\n\tPress-2 to Display the Equations";
cout<<"\n\tPress-3 to āfunction1ā, calculate the value of A divided by C for the value of x from 1 to 100";
cout<<"\n\tPress-4 to āfunction1ā, calculate the value of B divided by C for the value of x from 2 to 200";
cout<<"\n\tPress-0 to QUIT";
while(Flag<0 || Flag>4)
{
cout<<"\n\tEnter Option (0 to 4): "; cin>>Flag;
}
if(Flag==1)
{
cout<<"\n\tEnter Start: "; cin>>Start;
while(End <= Start)
{
cout<<"\n\tEnter End (> Start) : "; cin>>End;
}
}
if(Flag==2) Display();
if(Flag==3)
{
val = Func_A()/Func_C(Start,End);
cout<<"\n\n\tValue: A/C = "<<val;
}
if(Flag==4)
{
val = Func_B()/Func_C(Start,End);
cout<<"\n\n\tValue: B/C = "<<val;
}
Flag=-1;
}
}
Comments
Leave a comment