sum of arrays
C
/**
* C program to find sum of all elements of array
*/
#include <stdio.h>
#define MAX_SIZE 100
int main()
{
int arr[MAX_SIZE];
int i, n, sum=0;
/* Input size of the array */
printf("Enter size of the array: ");
scanf("%d", &n);
/* Input elements in array */
printf("Enter %d elements in the array: ", n);
for(i=0; i<n; i++)
{
scanf("%d", &arr[i]);
}
/*
* Add each array element to sum
*/
for(i=0; i<n; i++)
{
sum = sum + arr[i];
}
printf("Sum of all elements of array = %d", sum);
return 0;
}/**
* C program to find sum of all elements of array
*/
#include <stdio.h>
#define MAX_SIZE 100
int main()
{
int arr[MAX_SIZE];
int i, n, sum=0;
/* Input size of the array */
printf("Enter size of the array: ");
scanf("%d", &n);
/* Input elements in array */
printf("Enter %d elements in the array: ", n);
for(i=0; i<n; i++)
{
scanf("%d", &arr[i]);
// Add each array element to sum
sum += arr[i];
}
printf("Sum of all elements of array = %d", sum);
return 0;
}
Also in C:
- Title
- print integer to stdout using write or putchar?
- Category
- C
- Title
- Difference between ** and *
- Category
- C
- Title
- c zero out array
- Category
- C
- Title
- measure time in c
- Category
- C
- Title
- networkx remove attributes
- Category
- C
- Title
- use of matplotlib inline
- Category
- C
- Title
- resto de division recursiva
- Category
- C
- Title
- 233 pounds to inr
- Category
- C
- Title
- 'keras.backend' is not a package
- Category
- C
- Title
- error: dereferencing pointer to incomplete type
- Category
- C
- Title
- Assign integer value to pointer?
- Category
- C
- Title
- qtableview get selected row
- Category
- C
- Title
- arduino digital io pins
- Category
- C
- Title
- change no_turbo
- Category
- C
- Title
- ‘uint64_t’ was not declared in this scope
- Category
- C
- Title
- python web crawler
- Category
- C
- Title
- is c and c++ platform independent
- Category
- C
- Title
- tar cmd
- Category
- C
- Title
- how to ascii art in c
- Category
- C
- Title
- sum of arrays
- Category
- C
- Title
- calculate max of three numbers using ternary operator in c
- Category
- C
- Title
- read a binary file c
- Category
- C
- Title
- simpy process return value
- Category
- C
- Title
- fa fa-facebook
- Category
- C
- Title
- how to get random numbers in c
- Category
- C
- Title
- c bit access struct
- Category
- C
- Title
- docker run port mapping
- Category
- C
- Title
- pasar a binario recursivo
- Category
- C
- Title
- es fibo
- Category
- C
- Title
- c radians
- Category
- C
- Title
- dani
- Category
- C
- Title
- read files in c
- Category
- C
- Title
- duplicar cadena
- Category
- C
- Title
- msdos
- Category
- C
- Title
- how to only show tenths place in c
- Category
- C
- Title
- unordered_map
- Category
- C
- Title
- ModuleNotFoundError: No module named 'easydict'
- Category
- C
- Title
- heitai bestial
- Category
- C
- Title
- random en c
- Category
- C
- Title
- inurl:fiu.edu math faculty
- Category
- C
- Title
- write array of char to file in c
- Category
- C
- Title
- find string in all files powershell
- Category
- C
- Title
- what is the meaningof noremap
- Category
- C
- Title
- for loop in c
- Category
- C
- Title
- factorial of a given number in c
- Category
- C
- Title
- generate all permutations of string
- Category
- C
- Title
- c vs python
- Category
- C
- Title
- how to store a user input with spaces in c
- Category
- C
- Title
- 1 212 32123 4321234 543212345 in c
- Category
- C
- Title
- .\main.c:4:8: error: expected declaration specifiers or '...' before '\x6f726c64'
- Category
- C
- Title
- how to make a linked list in c
- Category
- C
- Title
- excel cell blank or zero
- Category
- C
- Title
- get current used proxy windows 7
- Category
- C
- Title
- long commands makes terminal lag after modifying PS1
- Category
- C
- Title
- c pause for 1 second
- Category
- C
- Title
- how can i remove a specific item from an array
- Category
- C
- Title
- binary tree geekd for geeks
- Category
- C
- Title
- where is my vimrc
- Category
- C
- Title
- c concatenate strings
- Category
- C
- Title
- what is restrict keyword in c
- Category
- C
- Title
- ModuleNotFoundError: No module named 'cv2'
- Category
- C
- Title
- how to create an array of char in c++
- Category
- C
- Title
- pi in c language
- Category
- C
- Title
- csrf_exempt
- Category
- C
- Title
- append to list in c
- Category
- C
- Title
- mangoosejs
- Category
- C
- Title
- write a binary file c
- Category
- C
- Title
- how to declare 2 d array using malloc
- Category
- C
- Title
- how to pass an array value to a pthread in c
- Category
- C
- Title
- bella ciao lyrics
- Category
- C
- Title
- what is stdin in c
- Category
- C
- Title
- fibonacci in c
- Category
- C
- Title
- vector aleatorio sin repetir
- Category
- C
- Title
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- Category
- C
- Title
- double return type in c
- Category
- C
- Title
- division recursiva
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- code in c skipping over scanf
- Category
- C
- Title
- c program to find the sum of given number using recursion
- Category
- C
- Title
- keras conv2d batchnorm
- Category
- C
- Title
- get regedit value cmd
- Category
- C
- Title
- typedef vs #define
- Category
- C
- Title
- c check if file was created
- Category
- C
- Title
- windowns 10 allow ping
- Category
- C
- Title
- how to feed a char array to function in C
- Category
- C
- Title
- c struct
- Category
- C
- Title
- Fibonacci program c pthread
- Category
- C
- Title
- div
- Category
- C
- Title
- hopw to check how many duplicates in an array c
- Category
- C
- Title
- multiplication operator in c
- Category
- C
- Title
- casting in c
- Category
- C
- Title
- battlefield4u.com
- Category
- C
- Title
- c isdigit function
- Category
- C
- Title
- california
- Category
- C
- Title
- how to find the ith row of pascal's triangle in c
- Category
- C
- Title
- command line arguments c
- Category
- C
- Title
- uint32_t extract first bits
- Category
- C
- Title
- get_session` is not available when using TensorFlow 2.0.
- Category
- C
- Title
- bubble sort time complexity
- Category
- C
- Title
- error 403
- Category
- C