pTutorial

New way to learn C programming

C program to calculate Array sum

C program to initialize array dynamically by using scanf function and calculate the sum of an array without using pre-define function.

C array example

#include <stdio.h>
#include <conio.h>
void main()
{
   int num, result = 0, j, array[50];
 
   printf("Enter the number of element =");
 
   scanf("%d", &num);
 
   for (j = 0; j < num; j++)
   {
      scanf("%d", &array[j]);
      
      result = result + array[j];
   }
 
   printf("Sum of array = %d\n",result);
   
   getch();
 
}

Download array sum example

Output of program

 Sum of array

C program to initialize array dynamically by using scanf function and calculate the sum of an array without using pre-define function.

See Also

  |   Angularjs radio button validation   |   Php mysql introduction

QUOTES OF THE DAY

Goal is tired by fire, brave men by adversity.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER