About 3,550 results
Open links in new tab
  1. C program to calculate sum, product of all One Dimensional Array Elements

    Logic to implement this program - Read array, Run a loop from 0 to N-1 and add each element in SUM variable and multiply each element in PRODUCT variable. Don’t forget to assign 0 in SUM and 1 in PRODUCT variables before running the loop. sum =0; . product =1; for(i =0; i <10; i ++) { . sum = sum + arr [i]; .

  2. One Dimensional Arrays in C - GeeksforGeeks

    May 3, 2024 · In this article, we will learn all about one-dimensional (1D) arrays in C, and see how to use them in our C program. A one-dimensional array can be viewed as a linear sequence of elements. We can only increase or decrease its size in a single direction.

  3. c - Multiplying Matrices in One-Dimensional Arrays - Stack Overflow

    May 10, 2017 · void multiply(int a[], int row1, int col1, int b[], int row2, int col2) { int d[size]; for (int i = 0; i < row1; i++) { for (int j = 0; j < col2; j++) { int sum = 0.0; for (int k = 0; k < col2; k++) sum = sum + a[i * col1 + k] * b[k * col2 + j]; d[i * col2 + j] = sum; } } for (int i = 0; i < size; i++) { if (i % col2 == 0) { printf("\n ...

  4. C Program to Perform Arithmetic Operations on Arrays

    In this C Program to Perform Arithmetic Operations on arrays, We declared 2 arrays or One Dimensional Arrays a, b with the size of 10. We also declared 4 more arrays Addition, Subtraction, Multiplication, and Module of integer type.

  5. C Program for One-Dimensional Array - CodesCracker

    C Program for One-Dimensional Array: In this article, you will learn and get code for using a one-dimensional (1D) array in a C program. For example, int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

  6. Matrix Multiplication using 1D arrays in C, formula and order?

    Jan 23, 2022 · This code is simpler to understand and does use a sum variable: void matrix_multiply (int m, int p, int n, double matrix1 [m] [p], double matrix2 [p] [n], double output [m] [n]) { for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { double sum = 0.0; for (int k = 0; k < p; k++) sum += matrix1 [i] [k] * matrix2 [k] [j]; output [i] [j] = su...

  7. Multiply each element of an array by a number in C

    May 24, 2013 · Using the for-loop would be the shortest way to accomplish what you're trying to do to the array. EDIT: If you have a large amount of data, there are more efficient (in terms of running time) ways to multiply 5 to each value.

  8. 1D Arrays in C | HackerRank Solution - CodingBroz

    In this challenge, create an array of size n dynamically, and read the values from stdin. Iterate the array calculating the sum of all elements. Print the sum and free the memory where the array is stored.

  9. One Dimensional Array Programs / Examples in C

    One Dimensional (One-D) Array Programs / Examples - This section contains solved programs on One Dimensional Array, here you will learn about declaration, initialisation of the array and other basic and advanced operations on array like reading, printing array elements, sum and product of array elements, merging two arrays, adding and ...

  10. One dimensional array in C - Tpoint Tech - Java

    Aug 28, 2024 · In this article, we'll dive deep into one-dimensional arrays in C programming language, including their syntax, examples, and output. The syntax of a one-dimensional array in C programming language is as follows: dataType specifies the data type of the array.

  11. Some results have been removed
Refresh