-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (62 loc) · 2.29 KB
/
main.cpp
File metadata and controls
66 lines (62 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(int argc,char** argv)
{
cout<<argv[0] <<"\n";
cout<<"replacing a letter or digit in a specific place --> ";
char *c;
c=argv[0];
cout<<c[20] <<" to with *c ";
c+=20;
*c='b';
cout<< *c << "\n";
cout<< " c[20] " << c[20] << "\n";
cout<< " &c[20] " << &c[20] <<"\n";
cout<<" and new c as a new modified 'string' " << c <<"\n";
cout<<"\n";
long double sqrt_num;
long double result_num;
int preci=-1;
cout<<"enter number : ";
cin>>sqrt_num;
cout<<"\n";
cout<<"enter result of sqrt number : ";
cin>>result_num;
cout<<"\n";
cout<<"enter precision : ";
cin>>preci;
cout<<"\n";
long double calculate_root;
calculate_root=sqrt(sqrt_num);
cout<<"want to change the result num to the precise square root result number ? \n";
cout<<"the square root result number based on math.h is : " <<std::setprecision(preci) << calculate_root <<"\n";
cout<<"press 1 to change or 0 to leave as is \n";
int xc=-1;
cin>>xc;
if(xc==1){result_num=calculate_root;}
cout<<"using only the integer part of the number \n";
long double rs_one;
rs_one=sqrt_num/9;
cout<<std::setprecision(preci) << sqrt_num << " / 9 ::== " <<std::setprecision(preci) << rs_one <<"\n";
long double xs_one;
long double fractpart,intpart;
fractpart=modf(rs_one,&intpart);
long double fr,intp;
fr=modf(result_num,&intp);
xs_one=intpart/intp;
cout<<std::setprecision(preci) << intpart << " / " << intp <<std::setprecision(preci) << " ::== " << xs_one <<"\n";
long double xre;
xre=intp/9;
cout<<std::setprecision(preci) << intp << " / 9 ::== " <<std::setprecision(preci) << xre <<"\n";
cout<<"\n";
cout<<"without intpart \n";
rs_one=sqrt_num/9;
cout<<std::setprecision(preci) << sqrt_num << " /9 ::== " << std::setprecision(preci) << rs_one <<"\n";
xs_one=rs_one/result_num;
cout<<std::setprecision(preci) << rs_one <<" / " << std::setprecision(preci) << result_num << " ::== " << std::setprecision(preci) << xs_one <<"\n";
xre=result_num/9;
cout<<std::setprecision(preci) << result_num << " / " << std::setprecision(preci) << " 9 ::== " << std::setprecision(preci) << xre <<"\n";
return 0;
}