Mzsmunna
10/16/2019 - 2:09 PM

Array summation with assignment


#include<stdio.h>

int main()
{
    int s, n, a, sum=0;
    printf("Input the number of array:\n\n");
    scanf("%d", &a);
    int p[a];
    printf("\nNow input the value for those %d array:\n\n", a);

    for(n=0;n<a;n++)
    {
        scanf("%d", &p[n]);
    }
    printf("\nThe total number of array and its individual value is:\n\n");

    for(n=0;n<a;n++)
    {
        printf("%d ", p[n]);
        sum=sum+p[n];
    }
    printf("\nSummation is : %d\n",sum);
    printf("\nNow Enter the value you want to search: ");
    scanf("%d", &s);

    for(a=0;a<n && s!=p[a]; a++)
    {

    }
    if (a < n)
        {
            printf("\nNumber found at the location = %d\n", a + 1);
        }
    else
        {
            printf("\nNumber not found\n");
        }

   return (0);
}