1 / 8

Declare an array:

Declare an array:. That can store 30 integers. That can hold 15 characters To store 150 values of resistance. For holding the marks of test1 and test2 for 50 students. With 100 elements of type double. Declare an array (ANSWER):. int aiExample [30]; char acM [150];

uta
Download Presentation

Declare an array:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Declare an array: • That can store 30 integers. • That can hold 15 characters • To store 150 values of resistance. • For holding the marks of test1 and test2 for 50 students. • With 100 elements of type double.

  2. Declare an array (ANSWER): • intaiExample [30]; • char acM [150]; • float afResistance [150]; • float marks [50] [2] ; • double adWhat [100];

  3. Consider the following code segment: intaFolly[6] = {5, 3, 2}; for (int x = 0; x < 6; x ++) { aFolly [x] = aFolly [x] + 3; } What is the value of aFolly[3] ? What is the value of element five ? What is the value of the second element ? Write a statement to print the first and the fourth element.

  4. Answer: When first declared: 5 3 2 0 0 0 After loop: 8 6 5 3 3 3 What is the value of aFolly[3] ? 3 What is the value of element five ? 3 What is the value of the second element ? 6 Write a statement to print the first and the fourth element. printf (“ %d %d “, aFolly [0] , aFolly [3] );

  5. Write C statements: • Declare a constant named MAX with value 15. • Declare an array of integers with MAX elements • Declare an array with 25 elements for storing wave lengths. • Display the third element of MyNumber. • Assign the value of 16.5 to the first and second elements of array XYZ

  6. ANSWER: • constint MAX = 15; OR #define MAX 15 • IntaiTry [MAX]; • float afWaveLengths [25]; • printf ( “%d “ , MyNumber [2] ); • XYZ [ 0 ] = 16.5; XYZ [1] = 16.5;

  7. Write C statements: • Access the fifth element of xArray. • Compare to see if the first element of aHM is more than 20. • Compare whether the element in b[3] is the same as 55. • Add the value of the current element to the next element.

  8. ANSWER: • xArray [4] ; • (aHM [0] > 20) • b[3] == 55 • adC [ num + 1] + = adC [num]; OR adC [num + 1] = adC [num + 1] + adC [num];

More Related