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.
I have written a code of this program. The code is too long. This frame is unable to show the code at a time.
উত্তরমুছুনyou can write main body as accepted as here...
উত্তরমুছুন#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();
#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);
}
#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);
}
Summer 2017
উত্তরমুছুনID#201610042
Answer to the Question No 4:
https://drive.google.com/file/d/0B99eePh0LV8gRWdBdEVXblR0UTA/view?usp=drivesdk
ID : 201620195
উত্তরমুছুনhttps://drive.google.com/open?id=0B9K31ospCyFjQnIxa0UwMXpFOFU
ID:201520552
উত্তরমুছুনhttps://drive.google.com/open?id=0B5pG0kIjzgEKYUdNZlZqREltMnM
ID 201610456
উত্তরমুছুনMD USUF MIA
https://drive.google.com/open?id=0B_PIGnOMR0K2Qy00VGFEZFlRY0E
https://drive.google.com/open?id=0Byxq3aat_mNSRWNMUFQyaTZER1U
উত্তরমুছুনID: 201620318
উত্তরমুছুনhttps://drive.google.com/open?id=0B2gcteJZycWod1Nzcm5USm5tYWs
https://drive.google.com/open?id=0B3bVD5Ppt_STek5zTjVXckNDM2s
উত্তরমুছুনID: 201710950
উত্তরমুছুনhttps://drive.google.com/open?id=0B1SMDOPeCkX_QWVXQjFnQURSM3c