30 Days Of Code
CtrlK
  • 30 Days Of Code
  • Index
    • Day 0: Hello, World.
    • Day 1: Data Types
    • Day 2: Operators
    • Day 3: Intro to Conditional Statements
    • Day 4: Class vs. Instance
    • Day 5: Loops
    • Day 6: Let's Review
    • Day 7: Arrays
    • Day 8: Dictionaries and Maps
    • Day 9: Recursion 3
    • Day 10: Binary Numbers
    • Day 11: 2D Arrays
    • Day 12: Inheritance
    • Day 13: Abstract Classes
    • Day 14: Scope
    • Day 15: Linked List
    • Day 16: Exceptions - String to Integer
    • Day 17: More Exceptions
    • Day 18: Queues and Stacks
    • Day 19: Interfaces
    • Day 20: Sorting
    • Day 21: Generics
    • Day 22: Binary Search Trees
    • Day 23: BST Level-Order Traversal
    • Day 24: More Linked Lists
    • Day 25: Running Time and Complexity
    • Day 26: Nested Logic
    • Day 27: Testing
    • Day 28: RegEx, Patterns, and Intro to Databases
    • Day 29: Bitwise AND
Powered by GitBook
On this page
  • Problem Link
  • Solution

Was this helpful?

  1. Index

Day 3: Intro to Conditional Statements

Problem Link

Solution

Conditional_Statements.cpp
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int Num;
    cin >> Num;
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    
    // Complete the solve function below.
    
    if(Num%2 == 0)
    {
        if(Num>=2 && Num<=5)
        {
            cout<<"Not Weird";
        }
        else if(Num>=6 && Num<=20)
        {
            cout<<"Weird";
        }    
        else
        {
            cout<<"Not Weird";
        }
    }
    else
        cout<<"Weird";
    return 0;
}
PreviousDay 2: OperatorsNextDay 4: Class vs. Instance

Last updated 4 years ago

Was this helpful?