ARRAYS can you please help me how to solve this ? Must be written in C. 1. Write
ID: 3699250 • Letter: A
Question
ARRAYS can you please help me how to solve this ? Must be written in C.
1. Write an initializer (one line) for the following:
A 2 dimmensional Boolean array called t i m e s , representing hours and minutes in a day, with 24 rows (hours) and 60 columns (minutes), for which times 3:45 and 19:34 are initialized to 1, the rest with 0.
2. Write a fragment of code that uses an array of integer values called d a t a (already declared and initialized) and add 5 to every element of d a t a whos index is divisible by 3. Your code should include declarations for any other additional variables needed for your solution.
Hint: s i z e o f function can be used to calculate the length of the d a t a array.
Explanation / Answer
here is the answer..
================================================================
Ans:1
===============================================================
bool times[24][60] = {0};
times[3][45] = 1;
times[19][34] = 1;
==============================================================
Ans:2
//array declration
int data[] = {1, 2, 3, 4,5, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7};
//calculate the size of the array
int size = sizeof(arr)/sizeof(int);
for(int i =0; i<size; i++)
{
//if index is divisible by 3
if(i%3 == 0)
{
arr[i] = arr[i] + 5;
}
===============================================================
Kindly Check and Verify Thanks..!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.