segmentation fault
//write a program to compute the sum of even and odd numbers stored in an array of N integers and print the same
#include<stdio.h>
void main()
{
int num[20];
int i,esum=0,odsum=0,N;
printf("enter the size of the array\n");
scanf("%d",&N);
printf("enter the elements one by one\n");
for(i=0;i<N;i++)
scanf("%d",num[i]);
for(i=0;i<N;i++)
{
if((num[i]%2)==0)
esum += num [i];
else
odsum += num[i];
}
printf("sum of even numbers=%d\n",esum);
printf("sum of odd numbers = %d\n",odsum);
}
what is the segmentation error in this programme?
how clear this error in this programme?
|