OODP Week 1 Programs
OODP Week 1 Programs
Week – 1
-Pranshu Bharti
RA2311033010104
CINTEL AK – 1
PROGRAM 1:
#include <iostream>
#include <iomanip>
int main ()
cout << setprecision(5) << "The value of pi : " << pi << endl;
cout << "The value of pi 4 decimal place of total width 8 :|" << setw(8) << pi << "|" << endl;
cout << "The value of pi 4 decimal place of total width 10 :|" << setw(10) << pi << "|" << endl;
cout << "The value of pi 4 decimal place of total width 8 :|" << setfill('-') << setw(8) << pi << "|" << endl;
cout << "The value of pi 4 decimal place of total width 10 :|" << setfill('-') << setw(10)<< pi << "|" << endl;
cout << "The value of pi in scientific format is : " << scientific << pi << endl;
cout << "Status in alphabet : " << (isalpha(pi) ? "true" : "false") << endl;
return 0;
OUTPUT:
Program 2:
#include <iostream>
#include <cmath>
int main()
cout << "Input the length of 1st side of the triangle : ";
cout << "Input the length of 2nd side of the triangle : ";
cout << "Input the length of 3rd side of the triangle : ";
s = (s1+s2+s3)/2;
cout << "The area of the triangle is : " << area << endl;
return 0;
OUTPUT:
PROGRAM 3:
#include <iostream>
using namespace std;
int main() {
int n, i = 6, j = 4;
cin >> n;
while (i--) {
while (j--) {
if (i == 5 || i == 0 || j == 3 || j == 0) cout << n;
else cout << " ";
}
cout << endl;
j = 4;
}
return 0;
}
OUTPUT:
PROGRAM 4:
#include <iostream>
int main()
int x;
cin>>x;
return 0;
OUTPUT:
PROGRAM 5:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double dis, la1, la2, lo1, lo2, e, r;
cout << "Print the distance between two points on the
surface of earth:";
cout << "----------------------------------------------------------"<<endl;
cout << " Input the latitude of coordinate 1: ";
cin >> la1;
cout << " Input the longitude of coordinate 1: ";
cin >> lo1;
cout << " Input the latitude of coordinate 2: ";
cin >> la2;
cout << " Input the longitude of coordinate 2: ";
cin >> lo2;
r = 0.01745327;
la1 = la1 * r;
la2 = la2 * r;
lo1 = lo1 * r;
lo2 = lo2 * r;
e = 6371.01;
dis= e*acos((sin(la1)*sin(la2))+(cos(la1)*cos(la2)*cos(lo1-
lo2)));
cout <<"The distance between those points is:
"<<dis<<endl;
return 0;
}
OUTPUT:
PROGRAM 6:
#include <iostream>
using namespace std;
int main() {
long int n1, n2, sum, p = 0;
cin >> n1 >> n2;
sum = n1 + n2;
while(sum) {
sum /= 10;
p++;
}
cout << p << endl;
return 0;
}
OUTPUT:
PROGRAM 7:
#include <iostream>
#include <iomanip>
int main() {
int n1;
long n2;
char n3;
float n4;
double n5;
return 0;
}
OUTPUT:
PROGRAM 8:
#include <iostream>
using namespace std;
int main() {
float deg_c, deg_f;
cin >> deg_c;
deg_f = deg_c * 9 / 5 + 32;
cout << deg_f << endl;
return 0;
}
OUTPUT:
PROGRAM 9:
#include <iostream>
int main() {
cout << "Sum = " << (n1*d2+n2*d1) << "/" << (d1*d2) << endl;
return 0;
OUTPUT:
PROGRAM 10:
#include <iostream>
#include <iomanip>
int main() {
cout << setw(12) << right << fixed << setprecision(2) << 23.987 << endl;
cout << setw(10) << scientific << setprecision(4) << -123.456 << endl;
return 0;
OUTPUT: