We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. Algorithms
  3. Warmup
  4. A Very Big Sum
  5. Discussions

A Very Big Sum

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

    You are viewing a single comment's thread. Return to all comments →

  • mraemiller 3 years ago+ 8 comments

    I tried it in pure C ...a world of pain! But here's the answer

    int main(){ int n; long bign = 0; long bignn; scanf("%d",&n); long arr[n]; for(int arr_i = 0; arr_i < n; arr_i++){ scanf("%li",&arr[arr_i]); } for(int arr_i = 0; arr_i < n; arr_i++){ bign = bign + (arr[arr_i]) ; } printf("%ld\n", bign); return 0; }

    -2|
    ParentPermalink
    • ranju73 3 years ago+ 0 comments

      wow!

      -1|
      ParentPermalink
    • tej005 3 years ago+ 0 comments

      cool!! was missing 'li' and 'ld' in the scanf statements...'l' for long..!! thank you.

      1|
      ParentPermalink
    • amantoor 3 years ago+ 0 comments

      Thanks!

      -1|
      ParentPermalink
    • mickey_sweety 3 years ago+ 0 comments

      not working

      0|
      ParentPermalink
    • somayaji 2 years ago+ 7 comments

      What's the reason for using two loops and an array? I feel like that just takes too much time and too much space. Here's my take in C if anyone's interested:

      #include <stdio.h>
      
      int main(void){
          int n;
          long sum=0;
          scanf("%d", &n);
          long value;
          //long arr[n];
          for (int i=0; i < n; i++) {
              scanf("%li", &value);
              sum += value;
          }
          printf("%li", sum);
          return 0;
      }
      
      9|
      ParentPermalink
      • apschauhan700 1 year ago+ 1 comment

        see full and easy to understand code on:

        https://github.com/akkshaychauhan/hacckerank-code/blob/master/Algorithms:A%20Very%20Big%20Sum

        0|
        ParentPermalink
        • thatsmemohit 12 months ago+ 3 comments

          Not working ...is there any place where I can see answers ?

          0|
          ParentPermalink
          • apschauhan700 12 months ago+ 0 comments

            https://github.com/akkshaychauhan/hacckerank-code

            0|
            ParentPermalink
          • apschauhan700 12 months ago+ 0 comments

            Try long long int in place of int if you are using c

            0|
            ParentPermalink
          • satyamskillz 5 months ago+ 0 comments

            take value as value[] it will surly work.

            0|
            ParentPermalink
      • Kanahaiya 12 months ago+ 0 comments

        you can check out the below link for video explanation :)

        https://github.com/Java-aid/Hackerrank-Solutions

        0|
        ParentPermalink
      • 158r1a04g3 9 months ago+ 1 comment

        thanks buddy , i learned something from your program :-)

        1|
        ParentPermalink
        • Kanahaiya 9 months ago+ 0 comments

          I am glad to know that my work helped you in your learning.

          0|
          ParentPermalink
      • vaasishteja 6 months ago+ 0 comments

        thank you it worked

        0|
        ParentPermalink
      • uniyalhimanshu08 5 months ago+ 0 comments

        but if we intializing array in long type after then we are inputing it and summing it then it is showing runtime error.. can you tell me why this happening or i am wrong??

        0|
        ParentPermalink
      • 180330049_CSE_A 4 months ago+ 1 comment

        I want to use functions in it . Can you give me the idea of it.

        0|
        ParentPermalink
        • Kanahaiya 2 months ago+ 0 comments

          you can check out the below link for video explanation :)

          https://github.com/Java-aid/Hackerrank-Solutions

          0|
          ParentPermalink
      • avinashraj2109 3 weeks ago+ 0 comments

        It will only run for numbers less than 10 digit not more than that.

        0|
        ParentPermalink
    • NiharPawade 2 years ago+ 0 comments

      "a world of pain" - completely agree with you.

      0|
      ParentPermalink
    • nikhil_lagwanka1 1 year ago+ 0 comments

      Does this work if you put the sum part under that function they have provided

      0|
      ParentPermalink
    • akshaya1833 2 months ago+ 0 comments

      THanks dude

      0|
      ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature