Saturday, May 31, 2014

Write a program to declare an integer array of 50 elements. A. Write a function getArray() to get array input from the user that will be used to initialize the first thirty five (35) elements of the array by getting input from the user. The rest of the 15 entries would be set to zero (0). B. Write a function FindEven() to find the total numbers of even numbers in the given array. C. Write a function ModifyArray() to make the each array element to a multiple of four(04). D. Write a function named ‘FindMin()’ that will find the smallest element in the given array and return the smallest element.

Write a program to declare an integer array of 50 elements.  
A. Write a function getArray() to get array input from the user  that will be used to initialize the first thirty  five (35) elements of the array by getting input from the user. The rest of the 15 entries would be set to zero (0).  
B. Write a function FindEven() to find the total numbers of even numbers in the given array.
C. Write a function ModifyArray() to make the each array element to a multiple of four(04).
D. Write a function named ‘FindMin()’ that will find the smallest element in the given array and return the smallest element.

#include<stdio.h>
void header()
{
    printf("\n\n\n\n\n\n\n\t\tBUILT AND DESIGNED BY >> ARSLAN UD DIN SHAFIQ\n\n\t\tWebsite>>\twww.CWorldbyAS.blogspot.com\n");
    printf("\n\t\tCOMSATS Institute of Information Technology,\n\n\t\t\t\t\t  Lahore , Pakistan\n\n\n");
}
void getArray(int a[])
{
    int i;
    for(i=0;i<35;i++)
    {
        printf("Enter %d Number : ",i+1);
        scanf("%d",&a[i]);
        printf("\n");
    }
    printf("\nYou Array's Elements are");
    for(i=0;i<50;i++)
    printf(" %d ",a[i]);
}
void even(int a[])
{
    int i;
    for (i=0;i<35;i++)
    {
        if (a[i]%2==0)
        printf("%d is Even\n",a[i]);
    }
}
int multiply(int a[])
{
    int i;
    for(i=0;i<35;i++)
    {
        printf("%d X 4 is %d\n",a[i],a[i]*4);
    }
}
int FindMin(int a[])
{
    int i,j,hold;
    for(j=0;j<35;j++)
    {
         for(i=0;i<35-1;i++)
         {
              if (a[i]>a[i+1])
              {
                  hold=a[i];
                  a[i]=a[i+1];
                  a[i+1]=a[i];
              }
         }
    }
        printf(" Minimum Number You have Entered is  %d ",a[0]);
        printf("\n\n\n\n\n");
}
int main()
{
    int a[50]={0},i;
    header();
    system("pause");
    system("cls");
    getArray(a);
    system("pause");
    system("cls");
    even(a);
    system("pause");
    system("cls");
    multiply(a);
    system("pause");
    system("cls");
    FindMin(a);
}

2 comments: