Question

Define a single dimensional array of size 6. Populate the array by a double nested loop...

Define a single dimensional array of size 6. Populate the array by a double nested loop using i and j as the loop variables. Index the array with i*2+j, and fill in the array with the value i + j. c programming

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

C CODE :

#include <stdio.h>

int main()
{
int array[6],temp=0,i,j,k; // initializing local variables and array with size 6
for(i = 0;;) // outer loop
{
for(j=0;j<6;j++) // inner loop
{
   temp = (i*2)+j; // logic
   array[temp] = i+j;
}
break;
}
printf("array elements are :"); // displaying resultant array
for(k=0;k<6;k++)
   {
   printf("\n %d",array[k]);
   }
return 0;
}

OUTPUT :

*New Project-20160908 白白root +《 compile ! Execute ! > Share Code main.cx 1 #include <stdio.h> main.c 3 int main() 4 int array

Add a comment
Know the answer?
Add Answer to:
Define a single dimensional array of size 6. Populate the array by a double nested loop...
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
  • In Java create an integer array named dice1 with a size of 10. Populate each array...

    In Java create an integer array named dice1 with a size of 10. Populate each array location with a roll of a six-sided die (hint: an int value of 1 through 6). Print the array out using an enhanced for loop. Sample output: Question 1 dice1 = 1 1 6 2 3 5 1 5 4 5

  • Write a java program that create a 2 dimensional array of type double of size 10...

    Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance

  • Write a piece of code that constructs a two-dimensional array of integers with 5 rows and...

    Write a piece of code that constructs a two-dimensional array of integers with 5 rows and 10 columns. Fill the array with a multiplication table, so that array element [i][j] contains the value i * j. Use nested for loops to build the array. java Program

  • Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array...

    Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array is randomly initialized (using Math.random()). Write a method to find the maximum value in this two dimensional array; Write a method to find the average value in the array; Write a method to count how many elements are smaller than average; Write a method to copy contents in a two-dimensional array to a one-dimensional array. The method will return this one-dimensional array. Method is...

  • C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array...

    C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...

  • In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61,...

    In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, and 66. Use a loop to call a method from main() that adds 15 points to all student grades that are a C or above. A C is defined as a score of 70 or above. Make this happen by passing the subscript value and not the entire array. The addition of the...

  • Create three variables for an int array, the size of the array, and a Scanner object...

    Create three variables for an int array, the size of the array, and a Scanner object to read keyboard input. Ask the user to specify the size of the array and then construct an int array of that size. Next, use a for loop to continuously ask the user to specify values for each location in the array. Lastly, print contents of the array as a histogram using the asterisk character (*). This will require using nested for loops. The...

  • Create a square array and fill out as shown below. Use a nested loop for this...

    Create a square array and fill out as shown below. Use a nested loop for this step. 1 3 5 7 9 2 4 6 8 10 3 5 7 9 11 4 6 8 10 12 5 7 9 11 13 Then create two 1D arrays to with row and column sum of the items. You have then 15 25 35 45 55 for the column sum, and 25 30 35 40 45 for the row sum. Print row...

  • (+30) Provide a python program which will Populate an array(list) of size 25 with integers in...

    (+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100)   to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0   (how many) Display the number of integers < 0   (how many) Display the...

  • in java / You will: // 1- create a square 2 dimensional array of random size...

    in java / You will: // 1- create a square 2 dimensional array of random size (less than 11) // 2- fill the array with random integers from 1 to the size limit // 3- print the array // 4- prompt to see if the user wants to do another //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 1- The square can use the same random value for x and y. Don't allow 0 size arrays. // 2- Maybe a nested set of for loops? to...

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