int firstNum, secondNum, count=0, sum=0;
cout << "a) Input two integers: firstNum and secondNum (firstNum must be less than secondNum)" << endl;
cin >> firstNum >> secondNum;
cout << endl;
cout << "b) ";
for (int i = firstNum; i <= secondNum; ++i)
if (i % 2 == 1)
cout << i << " ";
cout << endl;
for (int i = firstNum; i <= secondNum; ++i)
if (i % 2 == 0)
count += i;
cout << "c) Sum of all even numbers = " << count<<endl;
cout << "d) ";
for (int i = 1; i <= 10; ++i)
cout << "Number = " << i << " and square = " << i * i << endl;
for (int i = firstNum; i <= secondNum; ++i)
if (i % 2 == 1)
sum += i * i;
cout << "e) Sum of the square of the odd numbers: " << sum << endl;
cout << "f) ";
for (int i = 0; i < 26; ++i)
cout << char(i + 65) << " ";
Comments
Leave a comment