Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2016 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/aa34e9fe97ff530ffec6fb85638f5a2b to your computer and use it in GitHub Desktop.
Save anonymous/aa34e9fe97ff530ffec6fb85638f5a2b to your computer and use it in GitHub Desktop.
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