You are on page 1of 3

#include<conio.

h>

#include<stdio.h>

int main()

int s,n,i,a[50],d;

do

printf("Enter Number of Elements for Array=");

scanf("%d",&n);

printf("\nEnter Elements of Array=");

for(i=0;i<n;i++)

scanf("%d",&a[i]);

printf("\nEnter the Appropriate Number to Perform the Following Operations=");

printf("\n1:Addition of Elements of Array");

printf("\n2:Minimum Element in the Array");

printf("\n3:Search an Element in the Array \n");

scanf("%d",&s);

switch(s)

case 1 :

int j,add=0;

for(j=0;j<n;j++)

add=add+a[j];

printf("\nAddition of Elements is=%d",add);

break;

case 2 :

int k,m=a[0];

for(k=1;k<n;k++)
{

if(a[k]<m)

m=a[k];

printf("\nMinimum=%d",m);

break;

case 3 :

int l,h,c=0,loc;

printf("\nEnter the Number to be Searched in the Array=");

scanf("%d",&h);

for(l=0;l<n;l++)

if(a[l]==h)

loc=l;

c++;

break;

loc++;

if(c!=0)

printf("\nThe Number is Present in the Array at Location=%d",loc);

else

printf("\nThe Number is Not Present in the Array!!");

break;

default:

printf("\nEnter Correct Choice!!");


}

printf("\nEnter 1:Continue \n2:End=");

scanf("%d",&d);

}while(d==1);

You might also like