In: Computer Science
Make a C++ program that outputs these following numbers: 10 5 9 10 8 15 7 20 6 25
Please do not use functions. Only use while loop.
Thank you :)
Solution:
#include<iostream>
using namespace std;
int main()
{
int s1,s2,i=1;
//Initializing first element of 1st series to 10
//Initializing first element of 2nd series to 5
s1=10;
s2=5;
while(i<=5)
{
cout<<s1<<" ";
cout<<s2<<" ";
//The common difference of first series is -1
s1=s1-1;
//The common difference of second series is 5
s2=s2+5;
i++;
}
cout<<"\n";
return 0;
}
Output: