D. Provide the correct input to have the program print the sentence: Exactly! Good Job. Before submitting your answer, please check its correctness by executing the code. #include #include #include static int64_t linkin_park[] = { 90422, 19518, 39438, 91175, 68488, 80947 }; const static int N = sizeof(linkin_park)/sizeof(*linkin_park); static void fail(){ puts("Nope!"); exit(EXIT_FAILURE); } static void guns_n_roses(int64_t t, int64_t r, int64_t l){ if ( t - l / 7 + 3 * r / 11 ) fail(); } static void anthrax(int q, int64_t y){ if (q
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
D.
Provide the correct input to have the program print the sentence:
Exactly! Good Job.
Before submitting your answer, please check its correctness by executing the code.
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
static int64_t linkin_park[] = { 90422, 19518, 39438, 91175, 68488, 80947 };
const static int N = sizeof(linkin_park)/sizeof(*linkin_park);
static void fail(){
puts("Nope!");
exit(EXIT_FAILURE);
}
static void guns_n_roses(int64_t t, int64_t r, int64_t l){
if ( t - l / 7 + 3 * r / 11 )
fail();
}
static void anthrax(int q, int64_t y){
if (q<N) {
if ((q % 2) == 0)
anthrax(++q, y);
else anthrax(q + 1, y + linkin_park[q]);
} else if (y != 179290)
fail();
}
static void pink_floyd(int x, int64_t n){
int64_t h = n;
for(; x<N; ++x) {
if (x % 2)
continue;
h *= linkin_park[x];
}
if (h != 241557750)
fail();
}
int main(){
int64_t w, s, a;
printf("Please enter the right three numbers: ");
fflush(stdout);
if (scanf("%" SCNd64 " %" SCNd64 " %" SCNd64, &w, &s, &a) != 3)
fail();
linkin_park[0] = w;
linkin_park[5] = s;
linkin_park[4] = a;
anthrax(0, 67365);
pink_floyd(1, 5);
guns_n_roses(w, s, a);
puts("Exactly! Good job.");
}
Step by step
Solved in 4 steps with 2 images