



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is a sample midterm exam for the ENEE 114 course at the University of Maryland, College Park, covering programming concepts for engineers. The exam includes questions related to code segments, function outputs, and writing functions. It is for reference only and was used in the March 12, 1998 exam.
Typology: Assignments
1 / 6
This page cannot be seen from the preview
Don't miss anything!




int i=3; NUMBER OF ASTERISKS: 6 if (i<2) printf("****"); else printf("******");
int i=0; NUMBER OF ASTERISKS: ___________ while (i<12) { if ((i%3)==0) printf(""); i++; if ((i%4)==0) printf(""); }
int i=1, j=1; NUMBER OF ASTERISKS: ___________ while ((i+j)<10) { printf("*"); i++; j+=2; }
int i=3, j=7; NUMBER OF ASTERISKS: ___________ if (((i+4)(j–2)) < 30) printf(""); else if (((j+4)/i) <= 3) printf(""); else printf("**"); if (((i+3)<(j–7))&&(!(i+j < 20))&&(i)) printf(“****”); if ((!(i>1))||(!((j+4)<23))||(ij < 100)) printf(“*****”);
int i=6, j=17; NUMBER OF ASTERISKS: ___________ if ((i<j) && (j>=(36))) printf(""); else if (((2i)<j) || ((3i)<j)) printf(""); else if ((3i)==(j+1)) printf("**");
int i; NUMBER OF ASTERISKS: ___________ for (i=0; i<100; i+=10) { switch(i) { case 30: printf(""); break; case 60: printf(""); break; case 90: printf("****"); break; default: printf(""); break; } }
#include <stdio.h> int main(void) { int x[] = {4, 5, 11, 6, –1, 0, 3}; int i=2; printf("1: %d\n", x[3]); printf("2: %d\n", x[1] + x[4]); printf("3: %d\n", x[i++]); printf("4: %d\n", x[++i]); printf("5: %d\n", x[x[1]]); return 0; }
#include <stdio.h> int main(void) { int nums[] = {2, 1, 6, 1, 5, 1, 4}; int i, sum = 0; for (i=(–5); i<=5; i++) { if (i==0) i++; if (i<0) sum += nums[–i]; else sum += nums[i]; } printf("The sum is %d.\n", sum); return 0; }
#include <stdio.h> int main(void) { int x[] = {4, 5, 11, 8, 18, 0, 3}; int i=1, m=0; while (i<7) { if ((x[i]–x[i–1]) > m) m = x[i]; i++; } printf("Result: %d\n", m); return 0; }
#include <stdio.h> #define M 5
int main(void) { int A[M], i, sum=0; for (i=0; i<M; i++) { A[M–i–1] = i*2; } for (i=0; i<M; i++) { sum += A[i] * (i+1); } printf("The sum is %d.\n", sum); return 0; }
program output
program output
program output
program output
Code for function miles_driven(x):