C program for find even & odd no.s in the array , C/C++ Programming

Assignment Help:

C Program for FIND EVEN & ODD NO.S IN THE ARRAY

#include stdio.h>

#include string.h>

#include conio.h>

void main()

{

          int i=0,j=0, l_e[100],l_o[100];

          int a[100],odd=0,even=0,sum_even=0,sum_odd=0;

          float avg_e=0,avg_o=0;

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

          {

                   a[i]=0;

                   l_e[i]=0;

                   l_o[i]=0;

          }

          i=0;    clrscr();

          printf("\nENTER THE LIMIT OF ELEMENTS: ");

          scanf("%d",&j);

          for(i=0;i

          {

                   printf("\nENTER THE NO %d: ",i+1);

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

                    if(a[i]%2==0)

                   {

                             sum_even=sum_even+a[i];

                             even++;

                             avg_e=sum_even/even;

                             l_e[i]=a[i];

                   }

                   else

                   {

                             sum_odd=sum_odd+a[i];

                             odd++;

                             avg_o=sum_odd/odd;

                             l_o[i]=a[i];

                   }

          } i=0;

          printf("\nTHE EVEN NO.S ARE %d",even);

          printf("\nTHE ODD NO.S ARE %d",odd);

          printf("\nTHE TOTAL OF EVEN NO.S ARE %d",sum_even);

          printf("\nTHE TOTAL OF ODD NO.S ARE  %d",sum_odd);

          printf("\nTHE AVERAGE OF ALL EVEN NO.S IS %f",avg_e);

          printf("\nTHE AVERAGE OF ALL ODD NO.S IS  %f",avg_o);

 

          getch();

}

 

OUTPUT :

ENTER THE NO 1 1 : 2

ENTER THE NO 1 2 : 6

ENTER THE NO 1 3 : 3

ENTER THE NO 2 1 : 4

ENTER THE NO 2 2 : 7

ENTER THE NO 2 3 : 8

ENTER THE NO 3 1 : 9

ENTER THE NO 3 2 : 1

ENTER THE NO 3 3 : 2

 

NO ARE IN ASCENDING ORDER

1          2          2

3          4          6

7          8          9

 


Related Discussions:- C program for find even & odd no.s in the array

Bank account system, To implement a back account system for new users

To implement a back account system for new users

Cange to palindrome, A palindrome is a string that reads the same from the ...

A palindrome is a string that reads the same from the both the ends. Given a string S convert it to a palindrome by doing character replacement. Your takes is to convert S to palin

Define array of objects, Array of Objects A class is a template, which ...

Array of Objects A class is a template, which can contain data items as well as member functions to operate on the data items. Various objects of the class can also be declared

Explain operators in c language, Explain Operators in C Language? The C...

Explain Operators in C Language? The C language is very rich in built - in - operators and it places more significance on operators than do most other computer languages. The C

#title. sentinel controlled loop, #question.develop an algorithm using pseu...

#question.develop an algorithm using pseudocode for computing cos(x) and sin(x). use a sentinel controlled while loop. use the series definition of e^+-jx

Program to display the greatest common divisor , Many modern cryptography a...

Many modern cryptography algorithms require two numbers that are coprime, or sometimes referred to as relatively prime. Two numbers are coprime if their greatest common divisor is

Logic behind object oriented programming, In this we will take a closer loo...

In this we will take a closer look at the logic behind Object Oriented Programming.  Read through the pseudocode listed below and answer the following questions. Class Square

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd