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

Write a C++ program using variables, if-else and for-loops that asks the user fo

ID: 672594 • Letter: W

Question

Write a C++ program using variables, if-else and for-loops that asks the user for a number, N, and prints the first N numbers of the Fibonacci series. For example, if the user inputs “8”, the program prints 0, 1, 1, 2, 3, 5, 8, 13; i.e., the first eight numbers of the series. You are encouraged to read more about the Fibonacci series on the web.

Check+ or more.  Write a program using for loops with less than 3 “cout” statements in your code to print the following pattern:

*

***

*****

*******

*********

*********

*******

*****

***

*

Please explain each line of code means after "//" Thank you very much

Explanation / Answer

#include<iostream>

using namespace std;

main()
{
int n, f = 0, s = 1, next;

cout << "Enter the number of value:" << endl;
cin >> n;   

for ( int i = 0 ; i < n ; i++ )
{
if ( i <= 1 )
next = is;
else
{
next = f + s;
f = s;
s = next;
}
cout << next << endl;
}

return 0;
}

#include<iostream>

using namespace std;

main()
{
for(int i = 0; i < 5; i++){
    for(int j = 0; j <2*i + 1 ; j++)
        cout<<"*";   
    cout<<endl;
}
for(int i = 4; i >= 0; i--){
    for(int j = 0; j <=2*i + 1 ; j++)
        cout<<"*" ;    
    cout<<endl;
}


return 0;
}

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