<\/span><\/h2>\n\n\n\nGiven an integer,n<\/em><\/strong> , perform the following conditional actions:<\/p>\n\n\n\n- If n<\/em><\/strong> is odd, print
Weird<\/code><\/li>- If n<\/em><\/strong> is even and in the inclusive range of 2<\/strong> to 5<\/strong>, print
Not Weird<\/code><\/li>- If n<\/em><\/strong> is even and in the inclusive range of 6<\/strong> to 20<\/strong>, print
Weird<\/code><\/li>- If n<\/em><\/strong> is even and greater than 20<\/strong>, print
Not Weird<\/code><\/li><\/ul>\n\n\n\nComplete the stub code provided in your editor to print whether or not n<\/em><\/strong> is weird.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single line containing a positive integer, n<\/em><\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 1 <= n<\/em> <= 100 <\/strong><\/li><\/ul>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nPrint Weird if the number is weird; otherwise, print Not Weird.<\/code><\/pre>\n\n\n\nSample Input 0<\/strong><\/p>\n\n\n\n3<\/code><\/pre>\n\n\n\nSample Output 0<\/strong><\/p>\n\n\n\nWeird<\/code><\/pre>\n\n\n\nSample Input 1<\/strong><\/p>\n\n\n\n24<\/code><\/pre>\n\n\n\nSample Output 1<\/strong><\/p>\n\n\n\nNot Weird<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\nSample Case 0:<\/em> n<\/em> = 3<\/strong>
n<\/em><\/strong> is odd and odd numbers are weird, so we print Weird<\/code>.<\/p>\n\n\n\nSample Case 1:<\/em> n<\/em> = 24<\/strong>
n<\/em> > 20<\/strong> and n<\/em><\/strong> is even, so it is not weird. Thus, we print Not Weird<\/code>.<\/p>\n\n\n\n<\/span>Solution – Day 3: Into to Conditional Statements<\/strong><\/span><\/h2>\n\n\n\n<\/span>C<\/strong><\/span><\/h3>\n\n\n\n#include <assert.h>\n#include <limits.h>\n#include <math.h>\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\nchar* readline();\nint main()\n{\n char* N_endptr;\n char* N_str = readline();\n int N = strtol(N_str, &N_endptr, 10);\n \/\/ Complete the solve function below.\n \n if(N%2==0)\n {\n if(N>=2 && N<=5)\n {\n printf(\"Not Weird\"); \n }\n else if(N>=6 && N<=20)\n {\n printf(\"Weird\");\n }\n else\n {\n printf(\"Not Weird\");\n } \n }\n else\n {\n printf(\"Weird\"); \n }\n \n if (N_endptr == N_str || *N_endptr != '\\0') { exit(EXIT_FAILURE); }\n return 0;\n}\nchar* readline() {\n size_t alloc_length = 1024;\n size_t data_length = 0;\n char* data = malloc(alloc_length);\n while (true) {\n char* cursor = data + data_length;\n char* line = fgets(cursor, alloc_length - data_length, stdin);\n if (!line) { break; }\n data_length += strlen(cursor);\n if (data_length < alloc_length - 1 || data[data_length - 1] == '\\n') { break; }\n size_t new_length = alloc_length << 1;\n data = realloc(data, new_length);\n if (!data) { break; }\n alloc_length = new_length;\n }\n if (data[data_length - 1] == '\\n') {\n data[data_length - 1] = '\\0';\n }\n data = realloc(data, data_length);\n return data;\n}<\/pre>\n\n\n\n<\/span>C++<\/strong><\/span><\/h3>\n\n\n\n#include <bits\/stdc++.h>\n\nusing namespace std;\n\nint main()\n{\n int N;\n cin >> N;\n cin.ignore(numeric_limits<streamsize>::max(), '\\n');\n \/\/ Complete the solve function below.\n if(N%2==0)\n {\n if(N>=2 && N<=5)\n {\n cout<<\"Not Weird\";\n }\n else if(N>=6 && N<=20)\n {\n cout<<\"Weird\";\n } \n else\n {\n cout<<\"Not Weird\";\n }\n }\n else\n cout<<\"Weird\";\n return 0;\n}<\/pre>\n\n\n\n