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

Php min function   |   Php date   |   Php operator

QUOTES OF THE DAY

The heart of melody can never be put down.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER