File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed
Hackerrank solutions/30 days Of Code Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* Task
2
+ Given an integer,n , perform the following conditional actions:
3
+
4
+ If n is odd, print Weird
5
+ If n is even and in the inclusive range of 2 to 5 , print Not Weird
6
+ If n is even and in the inclusive range of 6 to 20, print Weird
7
+ If n is even and greater than 20, print Not Weird
8
+ Complete the stub code provided in your editor to print whether or not is weird.
9
+
10
+ Input Format
11
+
12
+ A single line containing a positive integer, n.
13
+
14
+ Constraints
15
+
16
+ 1<n<100
17
+
18
+ Output Format
19
+
20
+ Print Weird if the number is weird; otherwise, print Not Weird.
21
+
22
+ Sample Input 0
23
+
24
+ 3
25
+ Sample Output 0
26
+
27
+ Weird
28
+ Sample Input 1
29
+
30
+ 24
31
+ Sample Output 1
32
+
33
+ Not Weird
34
+ Explanation
35
+
36
+ Sample Case 0: n=3
37
+ n is odd and odd numbers are weird, so we print Weird.
38
+
39
+ Sample Case 1: n=24
40
+ n>20 and n is even, so it is not weird. Thus, we print Not Weird. */
41
+
42
+ #include <assert.h>
43
+ #include <limits.h>
44
+ #include <math.h>
45
+ #include <stdbool.h>
46
+ #include <stddef.h>
47
+ #include <stdint.h>
48
+ #include <stdio.h>
49
+ #include <stdlib.h>
50
+ #include <string.h>
51
+
52
+ int main ()
53
+ {
54
+ int i ;
55
+ scanf ("%d" ,& i );
56
+ if (i %2 == 0 )
57
+ {
58
+ if (i >=2 && i <=5 )
59
+ printf ("Not Weird" );
60
+ else if (i >=6 && i <=20 )
61
+ printf ("Weird" );
62
+ else
63
+ printf ("Not Weird" );
64
+ }
65
+ else {
66
+ printf ("Weird" );
67
+ }
68
+ }
You can’t perform that action at this time.
0 commit comments