Completely Solved C, C++ Programs Assignment.

 Quick Search Database Videos Tutorials Ebooks Forums FAQ Aboutus Household Industrial Manufacturing Service Shopping Transportation

### C Program which does the below process after reading on odd no of integer. a)Print them in given order. b) Replace second elements by product of first and last element c) Replace middle value by average of all elements. d) Replace all –ve no’s by zero’s

 Filed Under: Sample C program

Problem 72. C Program which does the below process after reading on odd no of integer.
a)Print them in given order.
b) Replace second elements by product of first and last element
c) Replace middle value by average of all elements.
d) Replace all –ve no’s by zero’s.
#include<stdio.h>
#include<conio.h>
main( )
{
int a[10],i,n,sum=0;
clrscr( );
printf(“enter the array sixe “);
scanf(“%d”,&n);
printf(“enter the elements”);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
sum=sum+a[i];
}
printf(“The given arrays is: “);
for(i=0;i<n;i++)
printf(“%d”,a[i]);
a[2]=a[1]*a[n-1];
printf(“n the given areay after replacing 2nd element is”);
for(i=0;i<n;i++)
printf(“%d”,a[i]);
a[(1+n/2)]=sum/n;
printf(“n the given array after replacing middle element by average of all”);
for(i=0;i<n;i++)
if(a[i]<0)
a[i]=0;
printf(“n given array after replacing –ve values by zero”);
for(i=0;i<n;i++)
printf(“%d”,a[i]);printf(“n”);
getch();
}

C compiler: gcc 4.1.2

Back to main directory: Sample C Program | Software Practical | Solved C Assignment