notes2

H function main begins program execution int main

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: gram 19 20 21 22 23 24 25 26 27 28 29 30 31 32 printf( "\nEnter two integers, and I will tell you\n" ); printf( "if at least one is even: " ); /* check if at least one integer is even */ scanf( "%d%d", &num3, &num4 ); /* read integer */ num3 % 2 == 0 || num4 % 2 == 0 ? printf( "\nAt least one integer is even.\n\n" ) : printf( "\nNeither integer is even.\n\n" ); return 0; /* indicate that program ended successfully */ } /* end function main */ Example Program with Logical NOT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /* example with logical NOT */ #include <stdio.h> /* function main begins program execution */ int main() { int num1; /* declare variables */ printf( "\nEnter a positive integer, and I will tell you\n" ); printf( "if it is divisible by 7: " ); scanf( "%d", &num1 ); /* read integer */ if ( !( num1 > 0) ) printf( "\nThe integer you entered is not positive.\n" ); else printf( "\n%d is%sdivisible by 7.\n", num1, num1 % 7 == 0 ? " " : " not " ); return 0; /* indicate that program ended successfully */ } /* end function main */ The while Repetition Statement • Repetition statement – Programmer specifies that an action is to be repeated while some condition remains true • while statement – Pseudocode While there are more items on my shopping list, Purchase...
View Full Document

Ask a homework question - tutors are online