Skip to content

Instantly share code, notes, and snippets.

/sumarray.c
Created Aug 2, 2016

Embed
What would you like to do?
Simple Array Sum
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
// https://www.hackerrank.com/challenges/simple-array-sum
int main(){
int n;
scanf("%d",&n);
int arr[n];
int sum = 0;
for(int arr_i = 0; arr_i < n; arr_i++){
scanf("%d",&arr[arr_i]);
sum += arr[arr_i];
}
printf("%i", sum);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.