Question

[2D array] [50 pts] In this question, you will create a 2-D array with name arr that stores the first 36 non-negative numbers it must be in C programming language ,

Thanks in advance!

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

SOURCE CODE:

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int main()
{
   int arr[6][6]; //declaring arr 2D array with 6rows and 6 cols
   int r,c,el=0;
   for(r=0;r<6;r++)
   {
       for(c=0;c<6;c++)
       {
           arr[r][c]=el++; //filling arr 2D array with 0 to 35 elements
       }
   }
   printf("arr 2D array is:-\n");
   for(r=0;r<6;r++)
   {
       for(c=0;c<6;c++)
       {
           printf("%d\t",arr[r][c]); //printing arr 2D array
       }
       printf("\n");
   }
   int arr2[2][2]; //declaring arr2 2D array with 2 rows and 2 cols
   for(r=0;r<6;r++)
   {
       for(c=0;c<6;c++) //iterating over arr 2D array
       {
           if(r==2 && c==2)
               arr2[0][0]=arr[r][c];
           if(r==2 && c==3)
               arr2[0][1]=arr[r][c]; //logic to fetch center 4 elements
           if(r==3 && c==2)
               arr2[1][0]=arr[r][c];
           if(r==3 && c==3)
               arr2[1][1]=arr[r][c];          
       }
   }
   printf("arr2 2D array is:-\n");
   for(r=0;r<2;r++)
   {
       for(c=0;c<2;c++)
       {
           printf("%d\t",arr2[r][c]); //printing arr2 2D array
       }
       printf("\n");
   }
   return 0;
}

SCREENSHOT:

#include<stdio.h> #include<conio.h> #include<stdlib.h> int main() int arr[6][6]; //declaring arr 2D array with brows and 6 co

// Logic to fetch center 4 elements r2LOLO if(r==2 && c==3) arr2[@][1]=arr[r][c]; if(n==3 && c==2) arr2[1][@]=arr[r][c]; if (

OUTPUT:

0 arr 2D array is: - 1 2 6 7 8 12 13 14 18 19 20 24 25 26 30 31 arr2 2D array is: - 14 15 20 21 3 9 15 21 27 33 4 10 16 22 28

Add a comment
Know the answer?
Add Answer to:
it must be in C programming language , Thanks in advance! [2D array] [50 pts] In...
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
  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items...

    Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items = new string[100, 4]; - Create a do while loop, when user enter "0", stop the loop. - User enter item name, price, quantity, save these info and subtotal to array. - increase "count++" -conver price(decimal, Convert.ToDecimal() ) and quantity(int) to do mulplication for subtotal - create a for loop (with count ) to cycle through the "items", display item name, price, quantity, and...

  • C++ This week, you are to create two separate programs, first using a simple array and...

    C++ This week, you are to create two separate programs, first using a simple array and the second using a 2D-array (matrix). [Part 1] Write a program that accepts exactly ten (10) integer numbers from the user and stores them in an array. In a separate for-loop, the program then goes through the elements in the array to print back: (i) The sum of the 10 numbers, (ii) the minimum value from the 10 numbers, and (iii) the maximum value...

  • Using C programming

    Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...

  • This must be a C PROGRAMMING script using ARRAY. Thank you :) 3. Create a script...

    This must be a C PROGRAMMING script using ARRAY. Thank you :) 3. Create a script that will take an array of numbers and show the numbers in reversed order. Size of Array and elements have to be prompted to the user. Another Array variable of the same type should keep the numbers in reversed order. a. b. EX) If A 11, 2, 3,4, 5) was chosen as input, the output 8 should be B-(5, 4, 3,2, 1

  • Microsoft Excel VBA (Visual Basic for Applications) Programming Language Objectives: Create an array and redim it...

    Microsoft Excel VBA (Visual Basic for Applications) Programming Language Objectives: Create an array and redim it to a size equal to an assigned value of a variable, populate the array with a series of random numbers, output the array to a message box and to a worksheet. Instructions: - Review the variables already declared. You won't need others. - See comments in the code that will act as your guide. Add new code directly after each comment. - Assign a...

  • c++ help please! Create a 2D character array in your main function and use nested for...

    c++ help please! Create a 2D character array in your main function and use nested for loops to fill the array with the letter ‘e’ to represent empty spaces. Create a function to print the board on the screen using a nested for loop. The function header is: void printBoard (char board [][3]) Create a function that checks whether a particular space has already been filled. If the space is filled it returns a boolean value of true, otherwise false....

  • Your goal is to create an ‘Array’ class that is able to hold multiple integer values....

    Your goal is to create an ‘Array’ class that is able to hold multiple integer values. The ‘Array’ class will be given functionality through the use of various overloaded operators You will be given the main() function for your program and must add code in order to achieve the desired result. Do not change any code in main(). If something is not working, you must change your own code, not the code in main(). Assignment 5: overloading member functions. Overview:...

  • Must be written in C 89 Mode Array Insertion Your task is to complete the implementation...

    Must be written in C 89 Mode Array Insertion Your task is to complete the implementation of the insertion function, insert_into_array: int* insert_into_array(int arr[], size_t arr_len, int value, size_t pos); The insertion function inserts a value into an array at a specified position. All elements to the right of the inserted element are shifted over a position (upon inserting, all elements at the insertion position are shifted up an index, and the last element in the array is overwritten by...

  • JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class....

    JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...

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