2 Solved Questions for Quiz 3 - Electrical Engineering Computations | ECE 206, Quizzes of Electrical and Electronics Engineering

Material Type: Quiz; Class: Electrical Engr Computations; Subject: Electrical And Computer Engr; University: University of Tennessee - Knoxville; Term: Unknown 1989;

Typology: Quizzes

Pre 2010

Uploaded on 09/17/2009

koofers-user-34u
koofers-user-34u 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Quiz #3 10/23/07 Name:____________________
1. Declare an integer array myArray with 10 elements. Initialize the 4th through the 8th
elements with odd numbers 1, 3, 5, 7, 9 using a for loop. (Note: be careful about the
array index)
int myArray[10];
int odd = 1;
for (int i = 3; i < 8; i++) {
myArray[i] = odd;
odd += 2; }
}
int myArray[10];
int oddarray[5] = {1, 3, 5, 7, 9};
for (int i = 3; i < 8; i++)
myArray[i] = oddarray[i-3];
1
3
5
7
9
myArray[0]
myArray[1]
myArray[2]
myArray[3]
myArray[4]
myArray[5]
myArray[6]
myArray[7]
myArray[8]
myArray[9]
pf2

Partial preview of the text

Download 2 Solved Questions for Quiz 3 - Electrical Engineering Computations | ECE 206 and more Quizzes Electrical and Electronics Engineering in PDF only on Docsity!

Quiz #3 10/23/07 Name:____________________

  1. Declare an integer array myArray with 10 elements. Initialize the 4th through the 8th elements with odd numbers 1, 3, 5, 7, 9 using a for loop. (Note: be careful about the array index) int myArray[10]; int odd = 1; for (int i = 3; i < 8; i++) { myArray[i] = odd; odd += 2; } } int myArray[10]; int oddarray[5] = {1, 3, 5, 7, 9}; for (int i = 3; i < 8; i++) myArray[i] = oddarray[i-3]; 1 3 5 7 9 myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] myArray[5] myArray[6] myArray[7] myArray[8] myArray[9]

Quiz #3 10/23/07 Name:____________________

int main() { int num = 1; // declare a reference of num, name it as numref int &numref = num; int &numref; numref = num; //wrong // declare a pointer pointing to num, name it as *numptr int numptr = # int * numptr; numptr = # // Ok // increase the value of num by 1 through reference variable numref numref++; // increase the value of num by 1 through pointer variable **numptr numptr++; // wrong ++numptr; // wrong (numptr)++; //ok ++numptr; //ok numptr = numptr+1;//ok }