prefix sum array
C++
#include <bits/stdc++.h>
using namespace std;
void fillPrefixSum(int arr[], int n, int prefixSum[])
{
prefixSum[0] = arr[0];
for (int i = 1; i < n; i++)
prefixSum[i] = prefixSum[i-1] + arr[i];
}
int main()
{
int arr[] = { 10, 4, 16, 20 };
int n = sizeof(arr) / sizeof(arr[0]);
int prefixSum[n];
fillPrefixSum(arr, n, prefixSum);
for (int i = 0; i < n; i++)
cout << prefixSum[i] << " ";
}
Also in C++:
- Title
- pair in c++
- Category
- C++
- Title
- function for searching in map in c++
- Category
- C++
- Title
- c++ reverse vector
- Category
- C++
- Title
- min in vector c++
- Category
- C++
- Title
- time conversion hackerrank solution in c++
- Category
- C++
- Title
- substr in c++
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- how to modulo 10^9+7
- Category
- C++
- Title
- how to find hcf in c++
- Category
- C++
- Title
- how initilaize deffult value to c++ class
- Category
- C++
- Title
- sfml base program
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- initialize vector of vector c++
- Category
- C++
- Title
- pbds in c++
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- Qt asynchronous HTTP request
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- vertical traversal of binary tree
- Category
- C++
- Title
- quick sort predefined function in c++
- Category
- C++
- Title
- c++ string
- Category
- C++
- Title
- write to file in C++
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- count number of zeros in array in O(logN)
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- class is replace by structure
- Category
- C++
- Title
- how to get a letter from the users string in c++
- Category
- C++
- Title
- basic ex of maps in c++
- Category
- C++
- Title
- pow c++
- Category
- C++
- Title
- how to calculate inverse trigonometric values in c++
- Category
- C++
- Title
- sort a string alphabetically c++
- Category
- C++
- Title
- compile c++ linux
- Category
- C++
- Title
- c++ char to string
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- c++ yes no question
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- random number in c++
- Category
- C++
- Title
- c++ program to find gcd of 3 numbers
- Category
- C++
- Title
- dijkstra in c++
- Category
- C++
- Title
- c++ ternary operator
- Category
- C++
- Title
- how to find length of string in c++
- Category
- C++
- Title
- split 2d array into chunks in c++
- Category
- C++
- Title
- c++ write string
- Category
- C++
- Title
- c++ sort array of ints
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- visual studio 2019 read and write text file c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- stoi c++
- Category
- C++
- Title
- hashset in c++
- Category
- C++
- Title
- how to use winmain function
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- c++ get type name of object
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- c++ ros subscriber
- Category
- C++
- Title
- char to string c++
- Category
- C++
- Title
- E/flutter (20384): [ERROR:flutter/third_party/txt/src/minikin/FontFamily.cpp(184)] Could not get cmap table size! E/flutter (20384): F/flutter (20384): [FATAL:flutter/third_party/txt/src/minikin/FontCollection.cpp(95)] nTypefaces == 0
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- iterative inorder traversal
- Category
- C++
- Title
- sleep system function linux c++
- Category
- C++
- Title
- c++ assert
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- else if c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- C++ Syntax
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- insertion sort in c++ program
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- c++ modulo make it give only positive numbers
- Category
- C++
- Title
- roscpp publish int32
- Category
- C++
- Title
- map insert c++
- Category
- C++
- Title
- double to float c++
- Category
- C++
- Title
- % operator in c++
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- min heap priority queue c++
- Category
- C++
- Title
- Insert into vector C++
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- set lower bound c++
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- iterate const vector
- Category
- C++
- Title
- c++ raw string
- Category
- C++
- Title
- c++ variable argument
- Category
- C++
- Title
- c++ while loop code
- Category
- C++
- Title
- matrix class in c++
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- removing repeated characters in a string c++
- Category
- C++
- Title
- cpp pi from acos
- Category
- C++