#include /* * Example from Sep 19, 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 arr[], int a); int main(void) { int celsius_temp = 0, d, e, fahrenheit_temp= 42, c=0, f= 42, x, i, j, k; double stockinfo[6][4] = {{4, 1.99, .25},{0,0,0}, {12, 87.95, 2.50}}; int multiD[2][3][4][5] = {{{{0}}}}; int scorelist[4] = {90,87,88,79}; float classavgs[20]= {0}; char nameclass[ ]= {'C','_','c','l','a','s','s','\0'}; char nameclass2[ ]="C 1320"; char notstring[ ] = {'f','o','o','t'}; double stockprice[6]={0}; char stocktype[6]={'X','A'}; char sti; x = 7; k=-1; printf(" \nbefore x (asz) is %d and k (returned asz) is %d ", x, k ); printf("\n\n\n"); printf("Table A"); for(i=0; i<4; i++) { printf("%cCol %d ",'\t',i); } printf("\n"); for(i=0; i<6; i++) { printf("Row %d \t",i); for (c=0; c<4; c++) { scorelist[c] = c*2; stockinfo[i][c] = ( (i==0)||(c==0) ? c+i : c*i ); // conditional expresssion is test ? trueanswer : falseanswer printf("si[%d][%d]=%lf %c", i, c, stockinfo[i][c], (c==3 ? '\n' :'\t' )); } } /* k = howdyfunc(scorelist, x); printf(" \nafter x (asz) is %d and k (returned asz) is %d ", x, k ); for (c=0; c<7; c++) { printf("\nafter Array[%d] is %d ",c, scorelist[c]); } */ /* for(i = 0; i < 7; i++) { // printf("scorelist[%d] = %d\t classavg[%d] is %f\t",i, scorelist[i],i,classavgs[i]); printf("nameclass letter is %c\t",nameclass[i]); printf("nc2 letter is %c\t",nameclass2[i]); printf("nstr letter is %c\n",notstring[i]); } printf("\nnameclass is %s\n", nameclass); printf("nameclass2 is %s\n", nameclass2); printf("notstring is %s\n", notstring); */ /* printf("\n\nnameclass is %s\n", nameclass); for(i = 0; ((i < 7) && (nameclass[i-1]!=' ')); i++) { printf("\nenter the %dth letter for the name\t",i); scanf("%c",&nameclass[i]); getchar(); printf("nc letter is %c\t",nameclass[i]); } printf("nameclass is %s\n", nameclass); printf("\nnameclass2 is %s\n", nameclass2); printf("\n\nPlease enter a 6 letter word :"); scanf("%s",nameclass2); printf("\nnameclass2 is %s\n", nameclass2); notstring[3]='\0'; printf("notstring is %s\n", notstring); */ /* for (i=0; i<5; i++) { printf("\nPlease enter a floating point number representing a price for location %d: ",i); scanf("%f", &classavgs[i]); } */ /* printf("\nPlease select the category you would like to give prices for. The categories are: "); i=0; while (stocktype[i] != 0) { printf("\n%c", stocktype[i]); i++; } // getchar(); scanf("%c",&sti); printf("\nYou entered %c",sti); if (sti == 'A') { printf("\nPlease enter a price for annuals: "); scanf("%f", &stockprice[3]); } else if (sti == 'N') { printf("\nPlease enter a price for native shrubs: "); scanf("%f", &stockprice[4]); } else if (sti == 'X') { printf("\nPlease enter a price for xeric perennials: "); scanf("%f", &stockprice[5]); } for(i = 0; i < 8; i++) { printf("classavgs[%d] is %f\n",i,classavgs[i]); } */ // 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); // // Arrays in C // 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); 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(); } */ // 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 arr[], int asz) { int c = -543; //printf("Howdy!! \n"); printf("\nbegin asz is %d",asz); for (c=0; c