Question

| ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l Unless you need to edit, its
0 0
Add a comment Improve this question Transcribed image text
Answer #1

11.
a. int alpha[10][20];
b.
for(int i=0;i<10;i++)
{
   for(int j=0;j<20;j++)
   {
       alpha[i][j]=0;
   }
}
c.
for(int i=0;i<10;i++)
{
   if(i==0)
   {
       for(j=0;j<20;j++) alpha[i][j]=1;
   }
   else
   {
       for(j=0;j<20;j++) alpha[i][j]=2;
   }
}
d.
for(int i=0;i<10;i++)
{
   alpha[i][0]=5;
}
for(int i=0;i<10;i++)
{
   for(int j=1;j<20;j++)
   {
       alpha[i][j]=2*alpha[i][j-1];
   }
}
e.
for(int i=0;i<10;i++)
{
   for(int j=0;j<20;j++)
   {
       cout<<alpha[i][j]<<" ";
   }
   cout<<endl;
}
f.
for(int j=0;j<20;j++)
{
   for(int i=0;i<10;i++)
   {
       cout<<alpha[i][j]<<" ";
   }
   cout<<endl;
}
12.
a.
void print(int arr[][],int rows,int cols)
{
   for(int i=0;i<rows;i++)
   {
       for(int j=0;j<cols;j++)
       {
           cout<<arr[i][j]<<" ";
       }
       cout<<endl;
   }
}
b.
print(times,30,7);
print(speed,15,7);
print(trees,100,7);
print(students,50,7);
13.

Code:
#include<iostream>
using namespace std;
int main()
{
   double alpha[50];
   int i;
   for(i=0;i<25;i++)
   {
       alpha[i]=i*i;
   }
   for(i=25;i<50;i++)
   {
       alpha[i]=3*i;
   }
   i=0;
   while(1)
   {
       int j=i;
       for(;j<i+10;j++)
       {
           cout<<alpha[j]<<" ";
       }
       cout<<endl;
       i+=10;
       if(i==50) break;
   }
   return 0;
}

Output:

014916 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 75 78 81 84 87 120 123 126 129 132 135 138
14.

Code:
#include<iostream>
using namespace std;
int smallestIndex(int *arr, int size)
{
   int mi = INT_MAX;int i,loc=-1;
   for(i=0;i<size;i++)
   {
       if(arr[i]<mi)
       {
           mi=arr[i];loc=i;
       }
   }
   return loc;
}
int main()
{
   int arr[]={82,45,67,33,46,33,54,23,556,23,54,656,343};
   cout<<smallestIndex(arr,13);
}

output:

Process exited after 2.316 seconds with return value e Press any key to continue . . .
15.
a.
struct tourType destination;
b.
destination.cityName="Chicago";
destination.distance=550;
destination.travelTime.hr=9;
destination.travelTime.min=30;
destination.travelTime.sec=0;

Add a comment
Know the answer?
Add Answer to:
| ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l U...
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
  •     (10 pts) Define a two-dimensional array named temp with three rows and four columns of type int such that the first...

        (10 pts) Define a two-dimensional array named temp with three rows and four columns of type int such that the first row is initialized to 6, 8, 12, 9; the second row is initialized to 10, 13, 6, 16; and the third row is initialized to 27, 5, 10, 20.     (10 pts) Consider the following declarations, and see p.566: enum brands = { GM, FORD, TOYOTA, BMW, KIA }; const int N_BRANDS = 5; const int COLOR_TYPES = 6; double...

  • Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that...

    Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that searches for a number in an array. T a. Write a bool function named search that receives 3 parameters: an int array, an int containing the length of the array, and an int number to search for. Return true if the number is in the array and false otherwise. b. Write a void function called fillArray with the array as a parameter that uses...

  • Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize...

    Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize your array using a text file, user input or assign value while declaring the array, you can choose the method. Then, a. Write a loop to print first row of the array on one line, using cout. b. Write a loop to print first column of the array on one line, using cout. c. Write a loop to print first five rows of the...

  • Assignment: Write a program with each of the following methods. You can assume this program is...

    Assignment: Write a program with each of the following methods. You can assume this program is saved in a file called multiArrays.java. A sample main method and sample output is provided at the end of this section. All arrays created are of integer-type. Write a method to declare, initialize, and populate a two-dimensional array. Using the following header:                         public static int[ ][ ] declare2D(Scanner scnr) The user will indicate the size of the array. Write a method to declare,...

  • Submit two C++ files: 1. Write a C++ program that declares an array alpha of 50...

    Submit two C++ files: 1. Write a C++ program that declares an array alpha of 50 components of type double. Initialize the array so that the first 25 components are equal to the square of the index variable, and the last 25 components are equal to three times the index variable. Output the array so that 10 elements per line are printed. 2. Write a program that prompts the user to input a string and outputs the string in uppercase...

  • /** * A collection of methods related to multi-dimensional arrays. */ public class Array2Lab { /**...

    /** * A collection of methods related to multi-dimensional arrays. */ public class Array2Lab { /** * Return whether k is in list. * Precondition: the elements of list are not null. * @param list the array to be searched. * @param k the number to search for. * @return true if k is an element of list, and false otherwise. */ public static boolean contains(Object[][] list, Object k) { return false; }    /** * Create a String that...

  • Excel.. Sav. Insert Design Layout References. Mailings Review View Help Tell me File Home Calibri (Body) Paste Cli...

    Excel.. Sav. Insert Design Layout References. Mailings Review View Help Tell me File Home Calibri (Body) Paste Clipboard Font Paragraph Styles R klomework #2 Due Tuesday May 28th, 2019 at 9:15AM This assignment deals with constructing contingency tables and calculating the probabilities of different events. Use the information in the Home Price dataset for the following questions. Use Excel to calculate your answers and format your spreadsheet so it is easily readable. Round all your answers to three decimal places....

  • Assignment 1. - Word File Insert Design Layout References Mailings Review View Tell me what you...

    Assignment 1. - Word File Insert Design Layout References Mailings Review View Tell me what you want to do Sign in Share Home Cut Find Aria E Copy Paste Select Editing Format Painter Clipboard Paragraph Font 9 leads to cell division when the target gene is transcribed. When the signal is present, will the target gene be Styles (5) The following is a diagram of the RTK signalling pathway. Assume that when the signal is present the pathway Ligand Receptor...

  • Write a C program to do the following...in this EXACT order: a. Declare an integer array...

    Write a C program to do the following...in this EXACT order: a. Declare an integer array named alpha of 50 elements. b. Use a for loopt to initialize each element of alpha to its index value (e.g. alpha[0] = 0, alpha[1]=1, etc.). c. Output the value of the first element of the array alpha. d. Output the value of the last element of alpha. e. Set the value of the 25th element of the array alpha to 62 and output...

  • I need help as quick as possible, thanks beforehand. Please provide the test output The Lo...

    I need help as quick as possible, thanks beforehand. Please provide the test output The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. 35 The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 - 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: 15 4 92 15 - 81 + 15 15 15...

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