a metreLoop through D gun at timensional array representing . the tool Inc.\" a
ID: 3605903 • Letter: A
Question
a metreLoop through D gun at timensional array representing . the tool Inc." a top three the red, column of a L-D army usung I his (re at a rested lasp) In a front ending top lie while(TRUE) punt at and on a th based not with a a) every center ton b) every at the bar c) every other aun rese han recasts dergy is there ) many front of e) Curion 3 iterichoa it is a trbona cci au omber S test to see Gven any * , ); Count value as welve 5) given a revory here R) (running mats he number of iterations will fe, retens the same It did on the first Call G Request to others from a veri and J print he saw and scal of the army eyArmyExplanation / Answer
Question 1:
int i, n;
int myArray[n][n]; // array of size n * n.
// loop through diagonal
for(i = 0; i < n; i++)
printf("%d", myArray[i][i]); // printing diagonal elements
Question 2:
int row, column = 2, width = 2;
int myArray[10][10];
// looping through 2nd, 5th and 9th column
for(row = 0; row <= 9; row++){
if(column <= 9)
printf("%d", myArray[row][column]; // printing 2nd, 5th and 9th column elements
if(row == 9 && column <= 9){ // To jump to next desired column
width++;
column = column + width;
row = 0;
}
}
Question 4:
int givenNo, a = 0, b = 1, c = 0;
while(c < givenNo){
c = a + b;
a = b;
b = c;
}
if(c == givenNo)
printf("Fibonacci number.");
else
printf("Not a fibonacci number.");
Question 5:
int givenNo, a = 0, b = 1, c = 0;
while(c < givenNo){
c = a + b;
a = b;
b = c;
}
if(c == givenNo)
printf("Fibonacci number.");
else
printf("Not a fibonacci number.");
Question 6:
int myArray[10][10];
int i, j; // stores ith row and jth column
printf(" Enter ith row: ");
scanf("%d", &i);
printf(" Enter jth column: ");
scanf("%d", &j);
printf("ith row and jth column element: ", myArray[i][j]);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.