90 likes | 212 Vues
ENGR 3. rocks. Your friendly TA Damon. Good list of VI commands http://ourldsfamily.com/mypapers/vi.html Good online free guide to Linux (time-sucker) http://www.linux.org/lessons/beginner/toc.html Good online free guide to C commands http://www.cs.cf.ac.uk/Dave/C/CE.html.
E N D
ENGR 3 rocks
Good list of VI commands • http://ourldsfamily.com/mypapers/vi.html • Good online free guide to Linux (time-sucker)http://www.linux.org/lessons/beginner/toc.html • Good online free guide to C commandshttp://www.cs.cf.ac.uk/Dave/C/CE.html
To search these websites use Google in the following way tcsh site:http://www.linux.orgor printf site:www.cs.cf.ac.uk/Dave/C
Homework 7 Let’s get ‘er done. A quick example: Ask user to enter an integer. Make C determine if the integer is even or odd. Tell the user if it is even or odd. If the user entered zero, warn them about it.
/*A prorgram that determines if an integer is even or odd.*/ #include<stdio.h> int main() { int integer; printf( "\nEnter an integer: " ); scanf( "%d", &integer ); /*If the user entered 0 then give error*/ if ( integer == 0 ) { printf(“Warning: Evenness of zero is disputed.\n"); return 1; }
/*use mod to determine if the integer is even*/ /*if the integer is divisible by 2 then it is even*/ if ( integer % 2 == 0 ) { printf( "It is an even integer.\n"); }/*if integer is not divisible by 2 then it must be odd*/ else { printf( "It is an odd integer.\n"); } return 0; }
% gcc evenodd.c -o evenodd.out % evenodd.out Enter an integer: 34.4 It is an even integer. % evenodd.out Enter an integer: 0 Warning: Evenness of zero is disputed.