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

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

 

Posted Date: 9/10/2012 7:42:42 AM | Location : United States







Related Discussions:- C program for find even & odd no.s in the array , Assignment Help, Ask Question on C program for find even & odd no.s in the array , Get Answer, Expert's Help, C program for find even & odd no.s in the array Discussions

Write discussion on C program for find even & odd no.s in the array
Your posts are moderated
Related Questions
Many human diseases could be controlled by the knowledge of the gene’s structure and pattern. The human gene could be represented by four nucleotides. Each nucleotide is represente

Explain the class invariant. - It's a condition that ensures correct working of a class and defines all the valid states for an object. - When an object is created class inv

What is a newline escape sequence? - A newline escape sequence is signified by the \n character. - It is used to insert a new line whereas displaying the output data. - T

Write a function that has int parameter n, makes another type of mask having n bit 1's from the left most bit and 32- n bit 0's next. The mask is called netmask in this seminar, an

Write a 3-4 page paper (350 words per page) in APA format detailing the development and use of C++ in academia and in industry. Explain the pros and cons of C++ as a programming la

Write a program that allows user to enter number of elements in an array. The program then allows user to enter the elements. Write a function called max that returns the position


I want a PROGRAM - Facebook auto like system to increase fans to different fanpage It has in a program that take Facebook mails and passwords from a excel file (.xlsx) for examp

Ask queByteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colo

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?