#include /* * Example from Sep 10, 2013 * Yes * a comment * */ #define FAHRFREEZE 32 #define CELCFREEZE 0 #define MAXVALS 10 #define MAX 20 //int z = 8; //A global variable will get a 0 on your lab in Dr T's class //int howdyfunc(int, int); int main(void) { int celsius_temp = 0, d, e, fahrenheit_temp= 42, c=0, f= 42, x; printf("Value of variable c is %d, d is %d, e is %d, f is %d max values are %d \n",c,d,e,f, MAXVALS); // control structures // sequential control - function call, assignment stmt // selection control - if, if - else // repetition control - // expression - evaluates to a numerical quantity // stmt - terminates with a ; and can be evaluated by the compiler // compound stmt - set of stmts grouped in curly braces printf("\nPlease enter two integer values seperated by a space: "); scanf("%d %d", &d, &e); f = d + c * e; printf("\n c before curly braces %d",c); /* if (c <= 10) { f = 543; // handle the small case } else if (c < 0) { f = c*e; f = f + d; printf("\n c in curly braces %d",c); // medium case } else if (c > 100) ; // large case */ c = 0; while (c >= 0) { x = (c<=9) + 3; printf("\n x and c in curly braces %d %d\n",x, c); printf("To continue, enter 1. To stop enter -1"); scanf("%d",&c); getchar(); } /* if ((c > 0) && (c < 10)) // && logical AND { } else if ((c > 50) || (c < 0)) // || logical OR { } else if ( ! (c == 0)) // ! logical NOT { } */ /* Pop quiz 10 Sep 13 */ // Declare 3 integer variables. int a1 = -17, a2 = 29, a3; // Assign values to the variables making at least one value negative. a3 = 10; // Calculate the sum of the three values. int sum = a1 + a2 + a3; // If the sum is greater than 10 or less than 0 if ((sum > 10) || (sum < 0)) // then print the three variables that you used to get the sum printf(" Values are %d %d %d", a1, a2, a3); // Else else // print the sum printf(" Value of sum is %d", sum); /* */ // a && b || !c || d && e // (((a && b) || (!c)) || (d && e)) printf("\n x and c after curly braces %d %d\n",x, c); int i = 0, j, k = 9; for (i = 0; i <= MAX ;i=k ) { k = k+i; j = k*k; printf("\nk is %d and j = %d and i = %d\n",k,j,i); } printf("You entered d= %d and e= %d. d+c*e where c= %d is %d\n",d,e,c,f); d = d * c + e; printf("You entered e= %d. d*c+e where c= %d is %d\n",e,c,d); d *= c + e; printf("You entered e= %d. d*c+e where c= %d is %d\n",e,c,d); e +=10; c -= 9; f = d + c * e; printf("You entered d= %d and e= %d. d+c*e where c= %d is %d\n",d,e,c,f); c = howdyfunc(e, d); printf("\nHello world %d\n Print a quote \" \n", howdyfunc(e,d) ); quizfunc(c, f); return 0; } int howdyfunc(int a, int b) { int c = -543; printf("Howdy!! \n"); quizfunc(b, c); return a; } /* Pop Quiz #1 August 29, 2013 Write a function that takes in two integers and declares one integer local variable and then prints all three values and returns 0. */ int quizfunc(int j, int k) { int l = 100; printf("THe three values are %d %d %d\n ",j, k, l); //quizfunc(, ); return 0; }