rashed
rashed
2- #include<iostream>
using namespace std;
int main()
{
cout<<"Rashed ";
cout<<"Ameen ";
cout<<"Alowsabi";
}
3- #include <iostream>
#include <windows.h>
using namespace std;
int main() {
string name,namefa;
int x = 0;
cout<<"Enter your name:";
cin>>name;
cout<<"Enter your father name:";
cin>>namefa;
while (true) {
system("cls");
cout << string(x, ' ') <<name<< " " <<namefa;
x++;
if (x > 50) break;
Sleep(50);
}
}
4- #include <iostream>
using namespace std;
int main() { int n;
cout << "Enter your number of star:";
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
cout << "* ";
cout << endl; }
}
5- #include <iostream>
using namespace std;
int main() {
int A = 5, B = 10;
cout << "A+B: " << A + B << endl;
cout << "A-B: " << A - B << endl;
cout << "A*B: " << A * B << endl;
cout << "A/B: " << A / B << endl;
6- #include <iostream>
using namespace std;
int main() {
int A, B;
cout << "Enter value of A: ";
cin >> A;
cout << "Enter value of B: ";
cin >> B;
cout << "Value of A+B: " << A + B << endl;
cout << "Value of A-B: " << A - B << endl;
cout << "Value of A*B: " << A * B << endl;
if (B != 0)
cout << "Value of A/B: " << A / B << endl;
}
7- #include <iostream>
using namespace std;
int main() {
int a, b, c;
cout<< "Enter number 1: ";
cin>>a;
cout<< "Enter number 2: ";
cin>>b;
cout<<"Enter number 3: ";
cin>>c;
int sum = a + b + c;
double average = (double)sum / 3;
cout<<"Sum: " << sum << endl;
cout<<"Average: "<< average << endl;
cout<<"Square of number 1: "<<a*a<< endl;
cout<<"Square of number 2: "<<b*b<< endl;
cout<<"Square of number 3: "<<c*c<< endl;
}
8- #include <iostream>
using namespace std;
int main() {
const int workingHours=120;
const int hourlyWage=45;
int salary = workingHours * hourlyWage;
cout <<"Employee salary: "<<salary<< endl;
}
9- #include <iostream>
using namespace std;
int main() {
int workingHours, hourlyWage;
cout << "Enter number of working hours: ";
cin >>workingHours;
cout << "Enter hourly wage: ";
cin >>hourlyWage;
int salary = workingHours * hourlyWage;
cout << "Employee salary: " << salary << endl;
}
if (num > 0) {
cout << "The Number Is Positive" << endl;
} else if (num < 0) {
cout << "The Number Is Negative" << endl;
} else {
cout << "The number is zero" << endl;
}
if (choice == 1) {
cout << "Result: " << num1 + num2 << endl;
} else if (choice == 2) {
cout << "Result: " << num1 - num2 << endl;
} else if (choice == 3) {
cout << "Result: " << num1 * num2 << endl;
} else if (choice == 4) {
if (num2 != 0) {
cout << "Result: " << num1 / num2 << endl;
} else {
cout << "Error: Division by zero" << endl;
}
} else {
cout << "Invalid choice" << endl;
}
switchﺑﺎﺳﺘﺨﺪام
#include <iostream>
using namespace std;
int main() {
int num1, num2, choice;
switch (choice) {
case 1:
cout << "Result: " << num1 + num2 << endl;
break;
case 2:
cout << "Result: " << num1 - num2 << endl;
break;
case 3:
cout << "Result: " << num1 * num2 << endl;
break;
case 4:
if (num2 != 0) {
cout << "Result: " << num1 / num2 << endl;
} else {
cout << "Error: Division by zero" << endl;
}
break;
default:
cout << "Invalid choice" << endl;
}
while (i <= n) {
sum += i * i;
i++;
}
do while statementﺑﺎﺳﺘﺨﺪام
#include <iostream>
using namespace std;
int main() {
int n, sum = 0, i = 1;
cout << "Enter a number: ";
cin >> n;
do {
sum += i * i;
i++;
} while (i <= n);
cout << "Last character in alphabetical order: " << lastChar << endl;
}
cout << "First character in alphabetical order: " << firstChar << endl;
}
20- #include <iostream>
#include <cmath>
using namespace std;
int main() {
double angle;
cout << "Enter an angle in degrees: ";
cin >> angle;
double sum = 0;
for (double num : numbers) {
sum += num;
}
int a = 0, b = 1, next;
int reversedNum = 0;
while (num > 0) {
reversedNum = reversedNum * 10 + num % 10;
num /= 10;
}
int evenSum = 0;
int oddSum = 0;
31- #include<iostream>
#include<math.h>
using namespace std;
int main() {
int n;
double x;
cout << "Enter the value of x: ";
cin >> x;
cout << "Enter the value of n: ";
cin >> n;
double sum = 0;
for (int i = 2; i <= n; i += 2) {
double factorial = 1;
for (int j = 1; j <= i; j++) {
factorial *= j;
}
sum += pow(x, i) / factorial;
}
while (i < 6) {
sum += numbers[i];
i++;
}
int main() {
double sum = 0;
double numbers[] = {5, 3, 1, 1.0, -3.0, -5.0};
int i = 0;
do {
sum += numbers[i];
i++;
} while (i < 6);
double sum = 0;
for (int i = 1; i <= I; i += 2) {
sum += 1.0 / i;
}