Σύνδεσμος ασκήσεων

Aσκήσεις c++
Print Hello World
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
ΠΡΟΣΘΕΣΗ ΔΥΟ ΑΡΙΘΜΩΝ
#include<iostream>
using namespace std;
int main()
{
int num1 = 10, num2 = 20, sum;
sum = num1 + num2;
cout << "Sum of Two Numbers " << num1 <<" and " << num2 << " = " << sum;
return 0;
}
ΓΙΝΟΜΕΝΟ ΔΙΑ 100
#include<iostream>
using namespace std;
int main()
{
float PA, ROI, time, si;
cout << "Please enter the Principal Amount : ";
cin >> PA;
cout << "Please enter the Rate Of Interest : ";
cin >> ROI;
cout << "Please enter the Time Period in Years : ";
cin >> time;
si = (PA * ROI * time) / 100;
cout << "\nSimple Interest = " << si;
return 0;
}
ΔΙΑΙΡΕΤΟΣ ΑΠΟ 5 ΚΑΙ 11
#include<iostream>
using namespace std;
int main()
{
int number;
cout << "\nEnter any Number to Check it is Divisible by 5 and 11 = ";
cin >> number;
if(( number % 5 == 0 ) && ( number % 11 == 0 ))
{
cout << "\nGiven number "<< number << " is Divisible by 5 and 11";
}
else
{
cout << "\nGiven number "<< number << " is Not Divisible by 5 and 11";
}
return 0;
}
ΑΝΑΖΗΤΗΣΗ ΔΙΑΙΡΕΣΗ ΜΕ ΘΕΣΗ ΠΙΝΑΚΑ;
#include<iostream>
using namespace std;
int main()
{
int a[9] = {1000, 500, 100, 50, 20, 10, 5, 2, 1};
int amount, i, temp;
cout << "\nPlease Enter the Amount of Cash = ";
cin >> amount;
temp = amount;
for(i = 0; i < 9; i++)
{
cout << a[i] <<" Notes is = " << temp / a[i] << endl;
temp = temp % a[i];
}
return 0;
}

ΤΥΠΩΝΩ ΑΠΟ 1 ΕΩΣ 100

#include<iostream>

using namespace std;

int main()

{

int number = 1;

while(number <= 100)

{

cout << number << " ";

number = number + 1;

}

return 0;

}

ΤΥΠΩΝΩ τους ΠΡΩΤΟΥΣ ΔΕΚΑ ΦΥΣΙΚΟΥΣ ΑΡΙΘΜΟΥΣ

#include<iostream>

using namespace std;

int main()

{

cout << "The First 10 Even Natural Numbers are\n";

for (int i = 1; i <= 10; i++)

{

cout << 2 * i << "\n";

}

}

Χωρίς το 2* αν μπει βγάζει 0,2,4...

ΤΥΠΩΝΩ ΑΠΟ Α ΕΩΣ Ζ

#include<iostream>

using namespace std;

int main()

{

cout << "\n---List of Alphabets between A and Z are---\n";

for(char alpCh = 'A'; alpCh <= 'Z'; alpCh++)

{

cout << alpCh << " ";

}

return 0;

}

ΤΥΠΩΝΩ ΜΙΚΡΑ α εως ζ

#include<iostream>

using namespace std;

int main()

{

cout << "\n---List of Lowercase Alphabets between a and z are---\n";

for(char lwalpCh = 'a'; lwalpCh <= 'z'; lwalpCh++)

{

cout << lwalpCh << " ";

}

return 0;

}

Ο ΜΕΓΑΛΥΤΕΡΟΣ ΑΠΟ ΔΥΟ
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout << "Please enter the Two Different Number = ";
cin >> x >> y;
if(x > y)
{
cout << x << " is Greater Than " << y;
}
else if(y > x)
{
cout << y << " is Greater Than " << x;
}
else
{
cout << "Both are Equal";
}
return 0;
}
ΜΕΓΑΛΥΤΕΡΟΣ ΑΠΟ ΤΡΕΙΣ
#include<iostream>
using namespace std;
int main()
{
int x, y, z;
cout << "Please enter the Three Different Number = ";
cin >> x >> y >> z;
if(x - y > 0 && x - z > 0)
{
cout << x << " is Greater Than both " << y << " and " << z;
}
else
{
if(y - z > 0)
{
cout << y << " is Greater Than both " << x << " and " << z;
}
else
{
cout << z << " is Greater Than both " << x << " and " << y;
}
}
return 0;
}
ΤΕΛΕΥΤΑΙΟ ΨΗΦΙΟ
#include<iostream>
using namespace std;
int main()
{
int number, lastDigit;
cout << "\nPlease Enter Any Number to find Last Digit = ";
cin >> number;
lastDigit = number % 10;
cout << "\nThe Last Digit in a Given Number " << number << " = " << lastDigit;
return 0;
}
ΕΛΑΧΙΣΤΟ ΚΟΙΝΟ ΠΟΛΛΑΠΛΑΣΙΟ
#include<iostream>
using namespace std;
int main()
{
int number1, number2;
cout << "\nPlease Enter the First Integer for LCM = ";
cin >> number1;
cout << "\nPlease Enter the Second Integer for LCM = ";
cin >> number2;
int maxValue = (number1 > number2)? number1 : number2;
while(1)
{
if(maxValue % number1 == 0 && maxValue % number2 == 0)
{
cout << "LCM of " << number1 << " and " << number2 << " = " << maxValue;
break;
}
++maxValue;
}
return 0;}

find Product of Digits in a Number

In this C++ product of digits in a number example, while loop checks whether the number is greater than 0.

  • reminder = number % 10 - It gives the last digit of a number.
  • digitProduct = digitProduct * reminder - It multiplies the last digit with digitProduct.
  • number = number / 10 - it removes the last digit from the number.

include<iostream>

using namespace std;

int main()

{

int number, reminder, digitProduct = 1;

cout << "\nPlease Enter the Number to find the Digits Product = ";

cin >> number;

while (number > 0)

{

reminder = number % 10;

digitProduct = digitProduct * reminder;

number = number / 10;

cout << "\nDigit = " << reminder << " and the Digit Product = " << digitProduct;

}

cout << "\n\nThe Product of all Digits in a given Number = " << digitProduct;

return 0;

}


ΔΙΕΚ ΑΙΓΙΝΑΣ 2021 - 2023 ΤΕΧΝΙΚΟΣ ΕΦΑΡΜΟΓΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ
Υλοποιήθηκε από τη Webnode Cookies
Δημιουργήστε δωρεάν ιστοσελίδα! Αυτή η ιστοσελίδα δημιουργήθηκε με τη Webnode. Δημιουργήστε τη δική σας δωρεάν σήμερα! Ξεκινήστε