# quiz3 - Tao Lin Quiz#3 EE140 /-/Quiz#3 Q1 Tao Lin /A...

This preview shows pages 1–2. Sign up to view the full content.

Quiz#3 EE140 //-------------------------------------------------------------------------- //Quiz#3 Q1 Tao Lin //A program that store positive integer numbers in an array and calculate //the sum of all even elements. //--------------------------------------------------------------------------- #include <stdio.h> int main( void ) { int ary[20],size,index,sum=0; printf( "Enter the number of elements in this array: " ); scanf( "%d" ,&size); for (index=0;index<size;index++) { printf( "Enter the No.%d integer: " ,index+1); scanf( "%d" ,&ary[index]); if (ary[index]%2==0) sum+=ary[index]; } printf( "The sum of all even integers in this array is: %d\n\n" ,sum); } RESULT: Enter the number of elements in this array: 12 Enter the No.1 integer: 1 Enter the No.2 integer: 2 Enter the No.3 integer: 5 Enter the No.4 integer: 6 Enter the No.5 integer: 9 Enter the No.6 integer: 4 Enter the No.7 integer: 8 Enter the No.8 integer: 3 Enter the No.9 integer: 7 Enter the No.10 integer: 4 Enter the No.11 integer: 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/04/2011 for the course EE 150 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

### Page1 / 2

quiz3 - Tao Lin Quiz#3 EE140 /-/Quiz#3 Q1 Tao Lin /A...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online