Question

Please I need code in C++ Write a program that creates an int array of size...

Please I need code in C++

Write a program that creates an int array of size 10, then uses a for-loop to populate the array with numbers from your favorite number pattern.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The program is for storing the the first 10 numbers of the fibonacci series in the array of size 10.

#include <iostream>

using namespace std;

int main()

{

int a=10;

int Fibonacci[a];

for (int i=0;i<a;i++)

{ if ( i ==0 )

{ Fibonacci[i] = 0; }

elseif (i == 1)

{ Fibonacci[i] = 1; }

else

{ Fibonacci[i] = Fibonacci [i=1] + Fibonacci [i-2]; }

}

for ( int i = 0;i < a; i++)

{ cout<< Fibonacci[i]; }

return( 0 );

}

Add a comment
Know the answer?
Add Answer to:
Please I need code in C++ Write a program that creates an int array of size...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please do the following programs in C++ complier. Do all the programs. I will give upvote...

    Please do the following programs in C++ complier. Do all the programs. I will give upvote straight away. 1) Write a program that uses a menu. Use a while loop in your code. Ensure your menu has an option to quit the program. 2)Write a program that creates an int array of size 10, then uses a for-loop to populate the array with numbers from your favorite number pattern. 3) Write a function that accepts an array as input then...

  • I need a c++ code please. 32. Program. Write a program that creates an integer constant...

    I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...

  • c++ help Write a program that: Creates two finite arrays of size 10 These arrays will...

    c++ help Write a program that: Creates two finite arrays of size 10 These arrays will serve as a storing mechanism for student grades in Classes A and B Uses a loop to populate the arrays with randomly generated numbers from 0 to 100.These numbers will represent student grades. Compute average grade of each class. Finally, output the two arrays and the message with two averages and best class. ("Class A average is: 65.43; class B average is: 68.90. Class...

  • Hello, I need a c program called int* create_random_array(int n) that returns a random array of...

    Hello, I need a c program called int* create_random_array(int n) that returns a random array of size an. Alternatively, you can initialize a pointer to an array (called Rand) and write a function called void(create_array(int * Rand, int n) which assigns an array of size n to Rand. Note: Plese utilize rand(fi) and srand() from stdlib.h for this code

  • need help editing or rewriting java code, I have this program running that creates random numbers...

    need help editing or rewriting java code, I have this program running that creates random numbers and finds min, max, median ect. from a group of numbers,array. I need to use a data class and a constructor to run the code instead of how I have it written right now. this is an example of what i'm being asked for. This is my code: import java.util.Random; import java.util.Scanner; public class RandomArray { // method to find the minimum number in...

  • I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){...

    I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){ int i; for(i = 0; i < asize;i++) printf("%d", array[i]); printf("\n"); } int sum(int array[], int asize){ int result = 0; int i = 0; for(i=0;i < asize;i++){ result = result + array[i]; } return result; } int swap( int* pA,int*pB){ int result = 0; if(*pA > pB){ int tamp = *pA; *pA = *pB; *pB = tamp; result = 1; } return result;...

  • Write a C++ program that reads a string and creates a cyclical array. A cyclical array...

    Write a C++ program that reads a string and creates a cyclical array. A cyclical array is an array when the last element is pointing to the first one. Then write a loop that uses pointers and loops through the array starting from the first element and finishes after it visits the first element 5 times.

  • I need this in python thank you 10.3 Code Practice Instructions Write a program that creates...

    I need this in python thank you 10.3 Code Practice Instructions Write a program that creates a 4 x 5 array called numbers . The elements in your array should all be random numbers between -30 and 30, inclusive. Then, print the array as a grid. For instance, the 2 x 2 array [[1,2],[3,4]] as a grid could be printed as: 1 2 34 Sample Output 18 -18 10 0 -7 -20 0 17 29 -26 14 20 27 4...

  • Write a program in C++ language that finds the largest number in an array of positive...

    Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...

  • c++ I have to write the following functions that I will later use for testt but...

    c++ I have to write the following functions that I will later use for testt but you just have to write the following functions again I have written the interface of it and please make sure it works. will have an array of randomly generated numbers - An array that is already sorted in ascending order - An array that is sorted in reverse (descending) order - An array that is sorted except for the last 10 numbers which are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT