0% found this document useful (0 votes)
30 views2 pages

Temă

The document contains 9 coding examples that perform various operations on input numbers. Example 1 reverses the digits of a 3-digit number. Example 2 checks if a number is between 1000-9999 and extracts the first and last digits. Example 3 sums the digits of a 3-4 digit number. Example 4 adds two numbers and displays the sum. Example 5 calculates the perimeter and area of a triangle given the lengths of the three sides. The rest of the document contains 50 multiple choice questions and their answers.

Uploaded by

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

Temă

The document contains 9 coding examples that perform various operations on input numbers. Example 1 reverses the digits of a 3-digit number. Example 2 checks if a number is between 1000-9999 and extracts the first and last digits. Example 3 sums the digits of a 3-4 digit number. Example 4 adds two numbers and displays the sum. Example 5 calculates the perimeter and area of a triangle given the lengths of the three sides. The rest of the document contains 50 multiple choice questions and their answers.

Uploaded by

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

Tem

Ex 2
#include<iostream>
using namespace std;
int main() {
int x;
do {

cin >> x;
} while (x <= 99 || x >=1000);
cout << x % 10 * 100 + x / 10 % 10 * 10 + x / 100;

Ex 4
#include<iostream>
using namespace std;
int main() {
int x;
do {

cin >> x;
} while (x < 1000|| x >9999);
cout << x / 1000 * 10 + x % 10;
}

Ex 5
#include<iostream>
using namespace std;
int main() {
int x;
do {

cin >> x;
} while (x < 1000|| x >9999);
cout << x % 1000 + x % 100 + x % 10;
}

Ex 6
#include<iostream>
using namespace std;
int main() {
float x,y;
do {

cin >> x>>y;


} while (x < 100 || x >999 && y < 100 || y>999);
Ex 7

cout << x+y/1000;}

#include<iostream>
#include<cmath>
using namespace std;
int main() {
int xa,ya,xb,yb;
cin >> xa >> ya >> xb >> yb;
cout << sqrt((xb - xa) ^ 2 + (yb - ya) ^ 2);
}
Ex 8
#include<iostream>
using namespace std;
int main() {
int x, y, xa, ya, xb, yb;
cin >> xa >> ya >> xb >> yb;
x = (xa + xb) / 2;
y = (ya + yb) / 2;
cout << x << y;
}
Ex 9
#include<iostream>
#include<cmath>
using namespace std;
int main() {
int x, y, xa, ya, xb, yb, xc, yc, AB, BC, CA, p;
cin >> xa >> ya >> xb >> yb >> xc >> yc;
AB= sqrt((xb - xa) ^ 2 + (yb - ya) ^ 2);
BC= sqrt((xc - xb) ^ 2 + (yc - yb) ^ 2);
CA= sqrt((xc - xa) ^ 2 + (yc - ya) ^ 2);
p = (AB + BC + CA) / 2;
cout << "Perimetrul triunghiului este:" << AB + BC + CA << endl;
cout << "Aria triunghiului este:" << sqrt(p*(p - BC)*(p - CA)*(p - AB));
}

Variante
21.c

31.b

41.a

22.b

32.d

42.b

23.d

33.c

43.a

24.d

34.a

44.d

25.c

35.c

45.b

26.c

36.b

46.c

27.a

37.c

47.d

28.b

38.d

48.a

29.a

39.d

49.b

30.d

40.c

50.b

You might also like