Array programming


Write a C Program to fill up an Integer Array. The length of the array must take from the terminal. After fill up the array do the following operations.
i)                    Print the array with label formatting.
ii)                   Count the number of values inside the array.
iii)                 Count the number of odd values.
iv)                 Count the number of even values.
v)                  Sum all the odd values.
vi)                 Sum all the even values.
vii)               Calculate the average.
viii)              Find the largest value.
ix)                 Find the smallest value.


<< Go to Index Page >>

13 মন্তব্যসমূহ

  1. I have written a code of this program. The code is too long. This frame is unable to show the code at a time.

    উত্তরমুছুন
  2. #include
    main()
    {
    int i, a[10],value,count=0,sum1=0,sum2=0,max=0,min=32678;
    float avg=0,sum=0;
    printf("Enter your enteger value:\n");
    for(i=0;i<10;i++)
    {
    scanf("%d",&value);
    a[i]=value;
    printf("[%d]=%d\n",i,a[i]);
    }
    for(i=0;i<10;i++)
    {
    count+=a[i];
    }
    printf("\n Sum inside array number:%d",count);
    for(i=0;i<10;i++)
    {
    if(a[i]%2==0)
    {
    printf("\n\n Even numberis:%d",a[i]);
    }
    }
    for(i=0;i<10;i++)
    {
    if(a[i]%2!=0)
    {
    printf("\n\n Odd numberis:%d",a[i]);
    }
    }
    for(i=0;i<10;i++)
    {
    if(a[i]%2==0)
    {
    sum1+=a[i];
    }
    }
    printf("\n Sum of even number:%d",sum1);
    for(i=0;i<10;i++)
    {
    if(a[i]%2!=0)
    {
    sum2+=a[i];
    }
    }
    printf("\n sum of Odd number:%d",sum2);
    for(i=0;i<10;i++)
    {
    sum+=a[i];
    }
    avg=sum/10;
    printf("\n avg=%.2f",avg);
    for(i=0;i<10;i++)
    {
    if(a[i]>max)
    {
    max=a[i];
    }
    }
    printf("\nLargest value:%d",max);
    for(i=0;i<10;i++)
    {
    if(a[i]<min)
    {
    min=a[i];
    }
    }
    printf("\nsmallest value:%d",min);
    getch();

    উত্তরমুছুন
  3. #include
    main()
    {
    int len,i,ceven=0,codd=0,evensum=0,oddsum=0,lar,sma;
    float avg=0;
    printf("Enter the size of the Array\n");
    scanf("%d",&len);
    int a[len];
    printf("Enter %d values for array\n",len);
    for(i=0;ilar)
    {
    lar=a[i];
    }
    }
    for(i=0;i<len;i++)
    {
    if (a[i]<sma)
    {
    sma=a[i];
    }
    }
    printf("\nThe largest element is: %d",lar);
    printf("\nThe smallest element is: %d",sma);
    }

    উত্তরমুছুন
  4. #include
    #define MAX 20
    #define AXE 20
    main()
    {
    int c,d,sum1=0,sum2=0,temp=0,count=0,i,n,count1=0,j;
    int a[MAX];
    printf("Enter the array size: ");
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
    printf("\n Enter %d value: ",i+1);
    scanf("\n %d", &a[i]);
    }
    int max = a[0];
    int min = a[0];

    for (i = 0; i max)
    {
    max = a[i];
    }
    else if (a[i] < min)
    {
    min = a[i];
    }
    }
    printf("\nArray Values: ");
    for(i = 0; i < n; i++)
    {
    printf("%3d ",a[i]);
    temp+=a[i];
    if(a[i]%2==0)
    {
    count++;
    sum1+=a[i];
    }
    else
    count1++;
    sum2=temp-sum1;
    }
    float b=temp/n;
    printf ("\nMaximum element in an array : %d\n", max);
    printf ("\nMinimum element in an array : %d\n", min);
    printf("\nthe avarage value of array is:%0.3f\n",b);
    printf("\nThe sum of array is:%d\n",temp);
    printf("\nThe number of even is:%d\n",count);
    printf("\nThe number of odd is:%d\n",count1);
    printf("\nThe sum of even is:%d\n",sum1);
    printf("\nThe sum of odd is:%d\n",sum2);
    }

    উত্তরমুছুন
  5. Summer 2017
    ID#201610042

    Answer to the Question No 4:

    https://drive.google.com/file/d/0B99eePh0LV8gRWdBdEVXblR0UTA/view?usp=drivesdk

    উত্তরমুছুন
  6. ID : 201620195
    https://drive.google.com/open?id=0B9K31ospCyFjQnIxa0UwMXpFOFU

    উত্তরমুছুন
  7. ID:201520552
    https://drive.google.com/open?id=0B5pG0kIjzgEKYUdNZlZqREltMnM

    উত্তরমুছুন
  8. ID 201610456
    MD USUF MIA
    https://drive.google.com/open?id=0B_PIGnOMR0K2Qy00VGFEZFlRY0E

    উত্তরমুছুন
  9. https://drive.google.com/open?id=0Byxq3aat_mNSRWNMUFQyaTZER1U

    উত্তরমুছুন
  10. ID: 201620318
    https://drive.google.com/open?id=0B2gcteJZycWod1Nzcm5USm5tYWs

    উত্তরমুছুন
  11. https://drive.google.com/open?id=0B3bVD5Ppt_STek5zTjVXckNDM2s

    উত্তরমুছুন
  12. ID: 201710950
    https://drive.google.com/open?id=0B1SMDOPeCkX_QWVXQjFnQURSM3c

    উত্তরমুছুন
নবীনতর পূর্বতন