Task 1:: Main (
Task 1:: Main (
#include<iostream>
using namespace std;
int main() {
int firstNum = 10;
int secondNum = 20;
swapbyref(firstNum, secondNum);
Task 2:
#include <iostream>
using namespace std;
void Series(double& R);
void Parallel(double& R);
int main()
{
int decision; double r; int Req = 0;
cout << "Press 0 to calculate resistance in Series" << endl;
cout << "Press 1 to calculate resistance in Parallel" << endl;
cin >> decision;
cout << " Enter the resistance (press -1 to end) " << endl;
if (decision == 0) {
cin >> r;
Series(r);
cout << "In series equilance resistance is : " << r << endl;
}
if (decision == 1)
{
cin >> r;
Parallel(r);
cout << "In Parallel equilance resistance is : " << r << endl;
}
return 0;
}
void Series(double& R) {
double Req = 0;
while (R != -1)
{
Req = Req + R;
cout << " Enter the resistance ( press -1 to end) " << endl;
cin >> R;
}
R = Req;
}
void Parallel(double& R) {
double Req = 0;
while (R != -1)
{
Req = Req + 1 / R;
cin >> R;
}
R = 1 / Req;
}
Task 3:
(a)
#include<iostream>
using namespace std;
void digits_counter(int&, int&);
int main()
{
int n;
int i = 0;
cout << " enter num : ";
cin >> n;
cout << endl;
while (n != 0) {
n = n / 10;
i++;
}
cout << "num of digits : ";
cout << i << endl;
return 0;
}
void digit_counter(int& n, int& i)
{
n;
}
(b)
#include<iostream>
using namespace std;
int r, re = 0;
while (n > 0) {
r = n % 10;
re = re * 10 + r;
n = n / 10;
}
*rev = re;
}
int main() {
int n, rev = 0;
cout << "Enter a number:";
cin >> n;
reverse(n, &rev);
cout << "Reverse number is:" << rev;
return 0;
}
(c)
#include<iostream>
using namespace std;
int r, rev = 0;
while (n > 0) {
r = n % 10;
rev = rev * 10 + r;
n = n / 10;
}
*p = rev;
}
int main() {
int n, p = 0;
palindrome_checker(n, &p);
if (p == n) {
cout << "Number is palindrome:" << n;
}
else {
cout << "Number is not palindrome:" << n;
}
return 0;
}