Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Output all odd numbers between firatNum and secondNum. Output the sum of all eve

ID: 3627175 • Letter: O

Question

Output all odd numbers between firatNum and secondNum. Output the sum of all even numbers between firatNum and secondNum. Output the numbers and their squars between 1 and 10. Output the sum of the square of the odd numbers between firstNum and SecondNum Output all uppercase letters. Redo Exercise 9 using for loops. Redo Exercise 9 using do..., while loops. The program in the Programming Example: Fibonacci Number does not check whether the first number entered by the user is less than or equal to the second number and whether both the numbers are nonnegative. Also the program does not check whether the user entered a valid value for the position of the derived number in the Fibonacci sequence. Rewrite that program so that it checks for these things. The population of a town A is less than the population of town it However, the population of town A is growing faster than the population of town B. Write a program that prompts the user to enter the population and growth rate of each town. The program outputs after how many years the population of town A will be greater than or equal to the population of town B and the populations of both the towns it that time. ( A sample input is: Population of town A = 5000, growth of town A = 4%, population of town B = 8000, and growth rate of since B = 2 %

Explanation / Answer

#include<iostream>

using namespace std;

void main()

{

int prev1,prev2,curr,count,nfib;

cout<<"Enter the first two fibonacci"<<"numbers:";

cin>>prev1>>prev2;

if((prev1>prev2)||(prev1==prev2)||(prev1<0||prev2<0))

{

cout<<"Enter the proper elements"<<endl;

exit(0);

system("pause");

}

cout<<"The first two fibonacci numbers are"<<prev1<<"and"<<prev2<<endl;

cout<<"Enter the position of the desired fibonacci number:"<<endl;

cin>>nfib;

if(nfib<=2)

{

cout<<"Enter the valid position"<<endl;

}

else if(nfib==1)

curr=prev1;

else if(nfib==2)

curr=prev2;

else

{

count=3;

while(count<=nfib)

{

curr=prev2+prev1;

prev1=prev2;

prev2=curr;

count++;

}

}

cout<<"The fibbonacci number at position"<<nfib<<" is"<<curr<<endl;

system("pause");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote