C programming Chapter 6 : page 266, 268, exercise 6.6 & 6.12 6.6 Fill in the bla
ID: 3690743 • Letter: C
Question
C programming
Chapter 6: page 266, 268, exercise 6.6 & 6.12
6.6 Fill in the blanks in each of the following:
a. C stores lists of values in .
b.The elements of an array are related by the fact that they .
c. When referring to an array element, the position number contained within square brackets is called a(n) .
d.The names of the five elements of array p are , , , and .
e. The contents of a particular element of an array is called the of that element.
f. Naming an array, stating its type and specifying the number of elements in the array is called the array.
g.The process of placing the elements of an array into either ascending or descending order is called .
h.In a double-subscripted array, the first subscript identifies the of an element and the second subscript identifies the of an element.
i. An m-by-n array contains rows, columns and elements.
j. The name of the element in row 3 and column 5 of array d is .
6.12 Write loops that perform each of the following single-subscripted array operations:
a. Initialize the 10 elements of integer array counts to zeros.
b.Add 1 to each of the 15 elements of integer array bonus.
c. Read the 12 values of floating-point array monthlyTemperatures from the keyboard.
d.Print the five values of integer array bestScores in column format.
5.8 Show the value of x after each of the following statements is performed: a. x fabs ( 7.5 b· x = floor ( 7.5 ); C. x = fabs ( 0.0 ) ; d. x = cell ( 0,0 ) ; e. x = fabs ( -6.4 ); f, x cell ( -6.4 ); g· x = cell ( -fabs ( -8 + floor ( -5.5 ) ) );Explanation / Answer
5.8)
a) #include <stdio.h>
#include <math.h>
int main()
{
printf("The absolute value x = %lf ", fabs(7.5));
}
output: The absolute value x = 7.500000
b) #include <stdio.h>
#include <math.h>
int main()
{
printf("x = %lf ", floor(7.5));
}
output: x = 7.000000
c) #include <stdio.h>
#include <math.h>
int main()
{
printf("The absolute value x = %lf ", fabs(0.0));
}
output: The absolute value x = 0.000000
d) #include <stdio.h>
#include <math.h>
int main()
{
printf(" x = %lf ", ceil(0.0));
}
output: x = 0.000000
e) #include <stdio.h>
#include <math.h>
int main()
{
printf(" The absolute value x = %lf ", fabs(-6.4));
}
output: The absolute value x = 6.400000
f) #include <stdio.h>
#include <math.h>
int main()
{
printf(" x = %lf ", ceil(-6.4));
}
output: x = -6.000000
g) #include <stdio.h>
#include <math.h>
int main()
{
printf(" x = %lf ", ceil( -fabs( -8 + floor(-5.5))));
}
output: x = -14.000000
6.6)
a. C stores lists of values in Arrays .
b.The elements of an array are related by the fact that they have same type of values .
c. When referring to an array element, the position number contained within square brackets is called a(n) subscript
d.The names of the five elements of array p are p[0] , p[1] , p[2] , p[3] and p[4] (if array index start from 0) .
e. The contents of a particular element of an array is called the subscript of that element.
f. Naming an array, stating its type and specifying the number of elements in the array is called declaring the array.
Declaring Arrays: type arrayName [ arraySize ];
g.The process of placing the elements of an array into either ascending or descending order is called Sorting
h.In a double-subscripted array, the first subscript identifies the Row of an element and the second subscript identifies the Column of an element.
i. An m-by-n array contains m rows, n columns and m*n elements.
j. The name of the element in row 3 and column 5 of array d is d[2][4] ( if row and column start with 0th index)
d[3][5] (if row and column start with 1as starting index )
6.12 )
a. Initialize the 10 elements of integer array counts to zeros.
Ans: for ( i = 0; i <= 9; i++ )
counts[ i ] = 0;
b.Add 1 to each of the 15 elements of integer array bonus.
Ans: int size =15, m;
int bonus[size];
for ( m = 0; m < size; ++m ) {
bonus[ m ] =m + 1;
}
for ( m = 0; m < size; ++m ) {
printf("%d ",bonus[m]);
}
c. Read the 12 values of floating-point array monthlyTemperatures from the keyboard.
Ans: int size = 11;
float monthlyTemperatures[size];
for ( i = 0; i < size ; i++ ) {
printf( “Enter the temperature: ” );
scanf( “%f”, &monthlyTemperatures[ i ] );
}
d. Print the five values of integer array bestScores in column format.
.Ans: for ( i = 0; i < 5; i++ ) {
printf( “%d ”, bestScores[ i ] );
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.