Hackerrank solution Simple Array Sum - Solution in C | Algorithms > Warmup - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Saturday, May 6, 2017

Hackerrank solution Simple Array Sum - Solution in C | Algorithms > Warmup

Hackerrank solution Simple Array Sum - Solution in C | Algorithms > Warmup


HackerRank Online Judge Solution  Simple Array Sum| Data structures
HackerRank Main Problem Link - https://www.hackerrank.com/challenges/simple-array-sum

Problem Name: HackerRank Problem Simple Array Sum
Problem Number : HackerRank Problem Simple Array Sum
Online Judge : HackerRank Online Judge Solution
Category: Algorithm
Solution Language : C, C plus plus

Hackerrank solution Simple Array Sum - Solution in C | Algorithms > Warmup


HackerRank Solution Simple Array Sum Code in C:


#include <stdio.h>

int main(){
    int n, sum = 0; 
    scanf("%d",&n);
    int arr[n];
    
    //take the value
    for(int arr_i = 0; arr_i < n; arr_i++){
       scanf("%d",&arr[arr_i]);
    }
    
    //print the sum
    for(int arr_i = 0; arr_i < n; arr_i++){
       sum += arr[arr_i];
    }
    printf("%d\n", sum);
    
    return 0;
}

No comments:

Post a Comment