0% found this document useful (0 votes)
19 views7 pages

Bodolt

The document contains multiple C++ programs that perform various mathematical operations and calculations. These include finding prime numbers, summing even or odd integers, calculating factorials, and checking conditions based on user input. Each program is structured with a main function and uses loops and conditional statements to achieve its goals.

Uploaded by

Da Hood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views7 pages

Bodolt

The document contains multiple C++ programs that perform various mathematical operations and calculations. These include finding prime numbers, summing even or odd integers, calculating factorials, and checking conditions based on user input. Each program is structured with a main function and uses loops and conditional statements to achieve its goals.

Uploaded by

Da Hood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

2.

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
int i, j;

for(i = 999, i > 100; i--;){


if(i < 100){
break;
}
if(i%2==1){
cout << i << endl;
}
}
}

3. #include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
int n, c1, c2, i, j;
cin >> n;

for(i = n, i != 100000000; i++;){


if(i%101==0){
c1 = i-n;
break;
}
}

for(i = n, i != -100000000; i--;){


if(i%101==0){
c2 = n-i;
break;
}
}

if(c1 < c2){


cout << n + c1;
}
else{
cout << n - c2;
}
}

6. x^e
7. #include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
int n, c1, c2, i, j;
cin >> n;

for (i = 1; i * i <= n; i++){


for (j = 1; j * j <= n; j++){
if(i*i + j*j == n){
cout << "true";
break;
}
}
}
cout << "false";
}

8. #include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
int n, c1 = 0, c2 = 0, i, j;
cin >> n;

for(i = 1000; i < 10000; i++){


if(i%133 == 125){
c1++;
}
if(i%134 == 111){
c2++;
}
}

cout << c1 << " " << c2;


}

9. #include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a >> b >> c >> d;

for(i = a; i < b; i++){


if(i%d==c){
count += 1;
}
}

cout << count;


}

10. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 2; i < a; i+=2){


count += i;
}

cout << count;


}

11. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 1; i < a; i+=2){


count += i;
}

cout << count;


}

12. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
float a, b, c, d, count = 0, i;
cin >> a;

for(i = 1; i < a+1; i++){


count += 1/i;
}

cout << count;


}

13. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
float a, b, c, d, count = 0, i;
cin >> a;

for(i = 1; i < a+1; i++){


count += i*i;
}

cout << count;


}

14. #include <iostream>


#include <bits/stdc++.h>
using namespace std;
int main(){
float a, b, c, d, count = 0, i;
cin >> a;

count = 1;
for(i = 3; i < a; i+= 2){
count -= 1/i;
}

cout << count;


}

15. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 2; i < a; i++){


if(a%i==0){
cout << "false";
break;
}
}
cout << "true";
}

17. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 0; i < 2000; i+=200+count*10){


count += 1;
}
cout << count;
}

18. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 2; i < a; i++){


if(a%i==0){
cout << i;
break;
}
}
}

19, 20. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 1; i < round(sqrt(a)); i++){


cout << i << " ";
}
}

21. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i;
cin >> a;

for(i = 1; i < 20; i++){


if(a%2!=0){
cout << "FALSE";
break;
}
}
cout << "TRUE";
}

22. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = 0, i, j;
cin >> a;

for(i = 1; i < 20; i++){


if(pow(2, i)>a){
cout << i;
break;
}
}
}

23. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int a, b, c, d, count = -1, i, j;
cin >> a;

a*= 100;
do {
count++;
a /= 10;
} while (a > 100);

if(count == 0){
cout << "NO";
}
else{
cout << a%10;
}
}

24. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int x, p, y, count = 0, i, j;
cin >> x >> p >> y;

do{
x += x/100*p;
x = round(x);
count++;
}while(x < y);

cout << count;


}

25. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int x, p, y, count = 0, i, j;
cin >> x;

do{
if(x%10%2==1){
cout << x%10;
break;
}
x /= 10;
}while(x > 0);
cout << "NO";
}

27. #include <iostream>


#include <bits/stdc++.h>
using namespace std;

int main(){
int x, p, y, count = 1, i, j;
cin >> x;

if(x==0 or x==1){
cout << 1;
}
else{
for(i = 2; i <= x; i++){
count *= i;
}
cout << count;
}
}

You might also like