1) Declare all variables needed and write the code to generate 20 random numbers
ID: 3775698 • Letter: 1
Question
1) Declare all variables needed and write the code to generate 20 random numbers In the range of 17 to 29. If the number is divisible by 6 or 4 display message "Multiple of 6 or 4" If the number is divisible by 3 or 5 display "Multiple of 3 or 5" Otherwise display "Not a multiple of 3, 4, or 5 or 6"
2) Assume an array is declared as int num[7]; Write a for loop which assigns the values 1,3,5, 7, 9, 11 and 13 to the successive array elements.
3)Write the code for a do while loop that checks for a valid entry of an integer, between 0 and 100 inclusive. If invalid it requests the user to re-enter until a valid number is submitted.
1) Declare all variables needed and write the code to generate 20 random numbers In the range of 17 to 29. If the number is divisible by 6 or 4 display message "Multiple of 6 or 4" If the number is divisible by 3 or 5 display "Multiple of 3 or 5" Otherwise display "Not a multiple of 3, 4, or 5 or 6"
2) Assume an array is declared as int num[7]; Write a for loop which assigns the values 1,3,5, 7, 9, 11 and 13 to the successive array elements.
3)Write the code for a do while loop that checks for a valid entry of an integer, between 0 and 100 inclusive. If invalid it requests the user to re-enter until a valid number is submitted.
1) Declare all variables needed and write the code to generate 20 random numbers In the range of 17 to 29. If the number is divisible by 6 or 4 display message "Multiple of 6 or 4" If the number is divisible by 3 or 5 display "Multiple of 3 or 5" Otherwise display "Not a multiple of 3, 4, or 5 or 6"
2) Assume an array is declared as int num[7]; Write a for loop which assigns the values 1,3,5, 7, 9, 11 and 13 to the successive array elements.
3)Write the code for a do while loop that checks for a valid entry of an integer, between 0 and 100 inclusive. If invalid it requests the user to re-enter until a valid number is submitted.
Explanation / Answer
#include<iostream>
#include<ctime>
using namespace std;
int input(int []);
int output(int[]);
int main()
{
int rNumb[50];
input (rNumb);
output (rNumb);
}
int input (int x[])
{
srand(time(0));
for(int i=0; i<50; i++)
x[i] = (rand()% 100)+1;
cout<< x[i] << end1;
return x[i];
}
int output (int x[])
{
for(int i = 0; i < 10; i++)
{
if(x[i] % 2 == 1)
cout << x[i] << " ";
}
return x[i];
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.