đŸ’ģ
C - Structured Programming Language
  • C - Structured Programming Language
  • Structured Programming Language
    • Chapter 0: Overview
      • Overview of Programming
      • Overview of C Programming
      • History of C Programming
      • IDE - Code::Blocks
      • New File Creation and Managing Program Files in Folders
      • C Program Basic Structure
      • Sections of the C Program
      • Steps for Using a Program
      • Flow of a Program Execution
      • First C Program - Hello World
      • Comment
      • Lexical Elements (/Tokens)
      • Keywords
      • Character Set
    • Chapter 1: Data Type, IO
      • Data Type
      • Variable
        • Variable Declaration for Primitive Data Type
        • Variable Address and Input
        • Constant and Macro
        • Variable Scope and Lifetime
        • Variable Storage Type
        • Variable Declaration Vs Definition Vs Initialization
        • Variable Default Value
        • Identifier Naming Rules and Conventions
      • Primitive Data Type: Format Specifier and Size
      • Literals
      • Primitive Data Type: Input Output
        • Input Output Function
        • Integer IO
        • Real Number IO
        • Character IO
        • String IO
        • Formatted Output
        • Formatted Input
        • Return of Scanf and Printf
      • IO Error
      • Escape Sequence / Backslash Characters
      • Data Type Modifiers
        • Data Type Size and Format Specifier
        • Input Output Using Modifiers
      • Data Type Limit
        • Integer Number
        • Floating Point Number
      • Memory Segment
      • Type Casting
      • Declaration of Derived Data Type
        • Array
        • Pointer
        • Function
        • Structure
        • Union
      • Declaration of User Defined Data Type
        • Enumeration
          • Enum Constant Value
          • Enumeration Exercise
        • Typedef
      • Declaration of Other Data Type
        • Boolean
        • Complex and Imaginary Number
        • File
        • Clock and Time
    • Chapter 2: Operator
      • Types of Operators
      • Assignment Operator
      • Arithmetic Operators
        • Math Operation
      • Increment, Decrement Operators
      • Relational Operators
      • Logical Operators
      • Bitwise Operators
      • Miscellaneous Operators
      • Operator Precedence and Associativity
      • Programming Syntax & Expression
      • Operator Exercise
    • Chapter 3: Conditional Statement
      • Truth Value
      • If Else Exercise
        • Zero, Positive, Negative - Number Sign Test
        • Voting Eligibility
        • Complex Numbers Equality
        • Different Example
          • Print a Digit into Word
          • Grade Evaluation
          • FizzBuzz
          • EVEN or ODD
          • Leap Year
          • Maximum of 2 Numbers
          • Maximum of 3 Numbers
          • Minimum of 2 Numbers
          • Minimum of 3 Numbers
      • Ternary Operator
        • Ternary Operator Exercise
      • Switch Statement
        • Switch Statement Exercise
    • Chapter 4: Loop
      • Loop Basic
      • Series Printing using Loop
      • Summation and Factorial
      • Loop Exercise
      • Number Theory
      • Break and Continue
      • Nested Loop
      • Managing Test Case
      • Goto Statement
    • Chapter 5: Pointer and Dynamic Memory Allocation
      • Pointer Fundamental Concept
        • Pointer Declaration
        • Types of Pointer
        • Pointer for Primitive Data Types
        • Pointer Referencing, Initialization, Accessing, Dereferencing
        • Pointer Size
      • Pointer Operation
        • Value Assignment/Update
        • Pointer Input Output
        • Pointer and Operator
          • Assignment Operator
          • Arithmetic Operator
          • Increment/Decrement Operator
          • Relational Operator
        • Pointer and Flow Control
      • Multilevel Pointer
      • Dynamic Memory Allocation (DMA)
        • Dynamic Memory Allocation (DMA)
        • DMA for Primitive Data Types
        • Pointer Operation after DMA
    • Chapter 6: Function & Recursion
      • Type of Function
      • Function Exercise
      • Conditional Statement and Function
      • Loop Exercise using Function
      • Pointer and Function
      • Recursion
        • Example
        • Pointer
    • Chapter 7: Array
      • Array Fundamental Concept
        • Necessity
        • Declaration (1D Array)
        • Initialization
        • Access
        • Assignment
        • Address
        • User Input
          • Test Case
      • Function and Array
      • Basic Array Operation
        • Statistical Operations
          • Summation
          • Average (Mean), Median
          • Frequency Table, Mode
          • Standard Deviation, Variance
          • Covariance, Correlation
        • Searching
          • Linear Search
          • Binary Search
          • Maximum
          • Minimum
        • Update
          • Index Based
          • Element Based
        • Delete
          • Index Based
          • Element Based
        • Insert
          • Index Based
          • Element Based
        • Sorting
          • Selection Sort
          • Insertion Sort
          • Bubble Sort
      • Other Array Operation
        • Copy
        • Reverse
        • Compare
        • Merge
        • Split
        • Cyclic Permutation
      • Pointer and Array
        • Basic
        • Insert
        • Delete
        • Summation
        • Reverse
        • Compare
        • Merge
        • Split
        • Cyclic Permutation
      • Pointer and Array
      • DMA and Array
      • 2D Array
    • Chapter 8: Character and String
      • Character
        • Declaration and Initialization
        • ASCII Code
        • Input Output
        • Conditional Statement
        • Character Arithmetic
      • String
        • String Declaration and Initialization
        • Input Output
        • Character Count in String
        • Character Conversion in String
        • String Operations
          • Substring
      • String and Pointer
    • Chapter 9: Structure
      • Basic of Structure
      • Structure Pointer
      • Function and Structure
      • Nested Structure
      • DMA and Structure
    • Chapter 10: File
    • Miscellaneous
      • Working with Math Functions
      • Working with Time Functions
      • Union
      • Preprocessor
      • Custom Header File
      • Error Handling
      • Graphics
      • Other
      • Coding Convention
      • Identifiers (Variable, Function & Structure) Naming Convention
      • Sizeof
      • Exit, Abort
      • Assert
    • Reference
      • Online Learning Material
  • Exercise
    • Problem Set 0: IDE, First C Program - 4
    • Problem Set 1: Data Types, IO - 55
      • Data Type, Variable, Format Specifier, Input, Output, String - 33
      • Data Type, Input, Output - 8
      • Data Type, Data Type Modifier, Format Specifier, Size, Limit, Address - 9
      • Formatted Input-Output - 4
    • Problem Set 2: Operator - 108
      • 2.1 Assignment Operator - 11
      • 2.2 Arithmetic Operator - 73
        • 2.2.1 Arithmetic Operator [5]
        • 2.2.2 Arithmetic Operator Exercise [10]
        • 2.2.3 Scale Conversion [25]
        • 2.2.4 Geometrical Shapes [35]
      • Bitwise Operator - 11
      • Use of Library Functions - 23
    • Problem Set 3: Conditional Statements - 47
    • Problem Set 4: Loop - 124
      • Sequence and Series - 33
      • More Loop Exercise - 52
      • Test Case - 7
      • Loop Nested - 32
    • Problem Set 5: Pointer and Dynamic Memory Allocation
      • Pointer Exercise
    • Problem Set 6: Function and Recursion - 42
      • Recursion
    • Problem Set 7: Array
      • One Dimensional Array - 114
      • Two Dimensional Array
    • Problem Set 8: Character and String - 61
      • Character - 29
      • String - 32
    • Problem Set 9: Structure
    • Problem Set 10: File
  • Solution
    • 0: IDE, First C Program
    • 1: Data Types, IO
    • 2: Operator
      • 2.1 Assignment Operator
      • 2.2 Arithmetic Operator
    • 3: Conditional Statements
      • 3.1 Conditional Statement
      • 3.2 Relational Operator
      • 3.3 Logical Operator
      • 3.4 Max, Min Median, Sorting
      • 3.5 Divisibility
    • 4: Loop
      • 4.1.1 Loop (Repetition)
      • 4.1.2 Print Sequence
      • 4.1.3 Summation of Series
      • 4.2 Loop Exercise
    • 5: Pointer and Dynamic Memory Allocation
    • 6: Function and Recursion
      • 5.1 Types of User Defined Function
      • 5.2 Exercise - Function
    • 7: Array
    • 8: Character and String
      • 7.1 Character Basic
      • 7.2 Character Input
      • 7.3 ASCII Code
      • 7.4 Character Test
      • 7.5 Character Conversion
      • 7.6 Character Arithmetic Operation
    • 9: Structure
    • 10: File
Powered by GitBook
On this page
  • ā§Š.⧍ āϰāĻŋāϞ⧇āĻļāύāĻžāϞ āĻ…āĻĒāĻžāϰ⧇āϟāϰ (ā§§ā§§)
  • āϏāĻŽāĻžāϧāĻžāύ
  • āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻž
  • [5] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤
  • [6] āĻāĻ•āϟāĻŋ āĻ…āĻ‚āĻ• āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇āϟāĻŋ āĻ•āĻĨāĻžā§Ÿ āϞāĻŋāĻ–āĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: One, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Two]
  • [7] 1-7 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŦāĻžāϰ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Sunday, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Monday]
  • [8] 1-12 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŽāĻžāϏ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: January, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: February]
  • [9] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āĻŦāĻ°ā§āĻ— āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [10] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āϘāύ āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • āϤ⧁āϞāύāĻž āĻ•āϰāĻž (āϛ⧋āϟ, āĻŦ⧜)
  • [11] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻŽāĻ§ā§āϝ⧇ āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤ (āϏāĻ‚āĻ–ā§āϝāĻž āĻĻ⧁āχāϟāĻŋ āϏāĻŽāĻžāύ, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āĻŦ⧜, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āϛ⧋āϟ)
  • [12] āĻĒāϰ⧀āĻ•ā§āώāĻžā§Ÿ āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āĻĒāĻžāĻļ/āĻĢ⧇āϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āĻĒāĻžāĻļ: 100-33, āĻĢ⧇āϞ: 32-00, āύ⧋āϟ: āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž)
  • [13] āϜāĻ¨ā§āĻŽ āϏāĻžāϞ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻāĻ•āϜāύ āĻŦā§āϝāĻžāĻ•ā§āϤāĻŋ āĻ­ā§‹āϟāĻžāϰ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [14] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻĒāϰāĻŽāĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [15] āĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ“ āĻŦāĻŋāĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ…āύ⧁āϏāĻžāϰ⧇ āϞāĻžāĻ­ āĻ…āĻĨāĻŦāĻž āϞ⧋āĻ•āϏāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  1. Solution
  2. 3: Conditional Statements

3.2 Relational Operator

ā§Š.⧍ āϰāĻŋāϞ⧇āĻļāύāĻžāϞ āĻ…āĻĒāĻžāϰ⧇āϟāϰ (ā§§ā§§)

  1. āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻž

    1. [5] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤

    2. [6] āĻāĻ•āϟāĻŋ āĻ…āĻ‚āĻ• āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇āϟāĻŋ āĻ•āĻĨāĻžā§Ÿ āϞāĻŋāĻ–āĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: One, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Two]

    3. [7] 1-7 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŦāĻžāϰ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Sunday, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Monday]

    4. [8] 1-12 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŽāĻžāϏ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: January, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: February]

    5. [9] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āĻŦāĻ°ā§āĻ— āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

    6. [10] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āϘāύ āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

  2. āϤ⧁āϞāύāĻž āĻ•āϰāĻž (āϛ⧋āϟ, āĻŦ⧜)

    1. [11] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻŽāĻ§ā§āϝ⧇ āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤ (āϏāĻ‚āĻ–ā§āϝāĻž āĻĻ⧁āχāϟāĻŋ āϏāĻŽāĻžāύ, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āĻŦ⧜, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āϛ⧋āϟ)

    2. [12] āĻĒāϰ⧀āĻ•ā§āώāĻžā§Ÿ āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āĻĒāĻžāĻļ/āĻĢ⧇āϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āĻĒāĻžāĻļ: 100-33, āĻĢ⧇āϞ: 32-00, āύ⧋āϟ: āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž)

    3. [13] āϜāĻ¨ā§āĻŽ āϏāĻžāϞ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻāĻ•āϜāύ āĻŦā§āϝāĻžāĻ•ā§āϤāĻŋ āĻ­ā§‹āϟāĻžāϰ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

    4. [14] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻĒāϰāĻŽāĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

    5. [15] āĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ“ āĻŦāĻŋāĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ…āύ⧁āϏāĻžāϰ⧇ āϞāĻžāĻ­ āĻ…āĻĨāĻŦāĻž āϞ⧋āĻ•āϏāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

āϏāĻŽāĻžāϧāĻžāύ

āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻž

[5] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int num1, num2;

    scanf("%d%d", &num1, &num2);

    // Compare the two numbers
    if(num1 == num2){
        // Print "Equal" if the numbers are the same
        printf("Equal\n");
    }
    else{
        // Print "Not Equal" if the numbers are different
        printf("Not Equal\n");
    }

    return 0;
}
Sample Input
Sample Output

1 1

Equal

1 2

Not Equal

[6] āĻāĻ•āϟāĻŋ āĻ…āĻ‚āĻ• āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇āϟāĻŋ āĻ•āĻĨāĻžā§Ÿ āϞāĻŋāĻ–āĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: One, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Two]

#include <stdio.h>

int main() {
    int digit;
    
    printf("Enter a digit (0-9): ");
    scanf("%d", &digit);

    if(digit == 0){
        printf("Zero\n");
    }
    else if(digit == 1){
        printf("One\n");
    }
    else if(digit == 2){
        printf("Two\n");
    }
    else if(digit == 3){
        printf("Three\n");
    }
    else if (digit == 4){
        printf("Four\n");
    }
    else if(digit == 5){
        printf("Five\n");
    }
    else if(digit == 6){
        printf("Six\n");
    }
    else if(digit == 7){
        printf("Seven\n");
    }
    else if(digit == 8){
        printf("Eight\n");
    }
    else if(digit == 9){
        printf("Nine\n");
    }
    else{
        printf("Invalid digit\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int digit;

    printf("Enter a digit (0-9): ");
    scanf("%d", &digit);

    switch (digit) {
        case 0: printf("Zero\n"); break;
        case 1: printf("One\n"); break;
        case 2: printf("Two\n"); break;
        case 3: printf("Three\n"); break;
        case 4: printf("Four\n"); break;
        case 5: printf("Five\n"); break;
        case 6: printf("Six\n"); break;
        case 7: printf("Seven\n"); break;
        case 8: printf("Eight\n"); break;
        case 9: printf("Nine\n"); break;
        default: printf("Invalid digit\n");
    }

    return 0;
}
Sample Input
Sample Output

0

Zero

1

One

2

Two

10

Invalid Digit

[7] 1-7 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŦāĻžāϰ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Sunday, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: Monday]

#include <stdio.h>

int main() {
    int day;
    
    printf("Enter a number between 1 and 7: ");
    scanf("%d", &day);

    if(day == 1){
        printf("Sunday\n");
    }
    else if(day == 2){
        printf("Monday\n");
    }
    else if(day == 3){
        printf("Tuesday\n");
    }
    else if(day == 4){
        printf("Wednesday\n");
    }
    else if(day == 5){
        printf("Thursday\n");
    }
    else if(day == 6){
        printf("Friday\n");
    }
    else if(day == 7){
        printf("Saturday\n");
    }
    else{
        printf("Invalid day\n");
    }
    
    return 0;
}
Sample Input
Sample Output

1

Sunday

4

Wednesday

7

Saturday

[8] 1-12 āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āϏ⧇ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻ•āĻŋ āĻŽāĻžāϏ āϤāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ [āχāύāĻĒ⧁āϟ: 1 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: January, āχāύāĻĒ⧁āϟ: 2 āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ: February]

#include <stdio.h>

int main() {
    int month;
    
    printf("Enter a number between 1 and 12: ");
    scanf("%d", &month);

    if(month == 1){
        printf("January\n");
    }
    else if(month == 2){
        printf("February\n");
    }
    else if(month == 3){
        printf("March\n");
    }
    else if (month == 4){
        printf("April\n");
    }
    else if(month == 5){
        printf("May\n");
    }
    else if(month == 6){
        printf("June\n");
    }
    else if(month == 7){
        printf("July\n");
    }
    else if(month == 8){
        printf("August\n");
    }
    else if(month == 9){
        printf("September\n");
    }
    else if(month == 10){
        printf("October\n");
    }
    else if(month == 11){
        printf("November\n");
    }
    else if(month == 12){
        printf("December\n");
    }
    else{
        printf("Invalid month\n");
    }
    
    return 0;
}
Sample Input
Sample Output

1

January

6

June

12

December

[9] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āĻŦāĻ°ā§āĻ— āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int num, sqrt_num;
    // Input number
    printf("Enter a number: ");
    scanf("%d", &num);

    // Check if the number is a perfect square
    if(num < 0){
        printf("Not a perfect square\n");
    }
    else{
        sqrt_num = (int)sqrt(num);
        if(sqrt_num * sqrt_num == num){
            printf("Perfect square\n");
        }
        else{
            printf("Not a perfect square\n");
        }
    }
    return 0;
}
Sample Input
Sample Output

16

Perfect square

14

Not a perfect square

25

Perfect square

[10] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§‚āĻ°ā§āĻŖ āϘāύ āϏāĻ‚āĻ–ā§āϝāĻž āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int num, cube_root;
    // Input number
    printf("Enter a number: ");
    scanf("%d", &num);

    // Check if the number is a perfect cube
    if(num < 0){
        printf("Not a perfect cube\n");
    }
    else{
        cube_root = (int)cbrt(num);
        if(cube_root * cube_root * cube_root == num){
            printf("Perfect cube\n");
        }
        else{
            printf("Not a perfect cube\n");
        }
    }
    return 0;
}
Sample Input
Sample Output

27

Perfect cube

14

Not a perfect cube

64

Perfect cube

āϤ⧁āϞāύāĻž āĻ•āϰāĻž (āϛ⧋āϟ, āĻŦ⧜)

[11] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻŽāĻ§ā§āϝ⧇ āϤ⧁āϞāύāĻž āĻ•āϰāĨ¤ (āϏāĻ‚āĻ–ā§āϝāĻž āĻĻ⧁āχāϟāĻŋ āϏāĻŽāĻžāύ, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āĻŦ⧜, ā§§āĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āϛ⧋āϟ)

#include<stdio.h>
int main(){
    int num1, num2;

    scanf("%d", &num1); // Read the first number
    scanf("%d", &num2); // Read the second number

    // Compare the two numbers
    if(num1 == num2){
        printf("The numbers are equal\n"); // Print if the numbers are equal
    }
    else if (num1 > num2){
        printf("The first number is greater\n"); // Print if the first number is greater
    }
    else{
        printf("The first number is smaller\n"); // Print if the first number is smaller
    }

    return 0;
}
Sample Input
Sample Output

5 5

The numbers are equal

8 5

The first number is greater

4 7

The first number is smaller

[12] āĻĒāϰ⧀āĻ•ā§āώāĻžā§Ÿ āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āχāύāĻĒ⧁āϟ āύāĻŋā§Ÿā§‡ āĻĒāĻžāĻļ/āĻĢ⧇āϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āĻĒāĻžāĻļ: 100-33, āĻĢ⧇āϞ: 32-00, āύ⧋āϟ: āĻĒā§āϰāĻžāĻĒā§āϤ āύāĻŽā§āĻŦāϰ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž)

#include<stdio.h>
int main(){
    int marks;

    scanf("%d", &marks);

    // Determine if the student has passed or failed
    if(marks >= 33){
        // Print "Pass" if the marks are 33 or above
        printf("Pass\n");
    }
    else{
        // Print "Fail" if the marks are below 33
        printf("Fail\n");
    }

    return 0;
}
Sample Input
Sample Output

35

Pass

20

Fail

[13] āϜāĻ¨ā§āĻŽ āϏāĻžāϞ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻāĻ•āϜāύ āĻŦā§āϝāĻžāĻ•ā§āϤāĻŋ āĻ­ā§‹āϟāĻžāϰ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int birth_year;
    int current_year = 2024;
    int age;

    scanf("%d", &birth_year);

    age = current_year - birth_year;

    // Determine if the person is eligible to vote
    if(age >= 18){
        printf("Eligible to vote\n");
    }
    else{
        printf("Not eligible to vote\n");
    }

    return 0;
}
Sample Input
Sample Output

2010

Not eligible to vote

1998

Eligible to vote

[14] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻĒāϰāĻŽāĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int number;

    scanf("%d", &number);
    
    if(number < 0){
        printf("%d\n", -number);
    }
    else{
        printf("%d\n", number);
    }

    return 0;
}
Sample Input
Sample Output

-7

7

3

3

0

0

[15] āĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ“ āĻŦāĻŋāĻ•ā§āϰ⧟āĻŽā§‚āĻ˛ā§āϝ āĻ…āύ⧁āϏāĻžāϰ⧇ āϞāĻžāĻ­ āĻ…āĻĨāĻŦāĻž āϞ⧋āĻ•āϏāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main() {
    float cost_price, selling_price;

    printf("Enter cost price: ");
    scanf("%f", &cost_price);
    printf("Enter selling price: ");
    scanf("%f", &selling_price);

    // Determine profit or loss
    if(selling_price > cost_price){
        printf("Profit: %.2f\n", selling_price - cost_price); // Print profit
    }
    else if(selling_price < cost_price){
        printf("Loss: %.2f\n", cost_price - selling_price); // Print loss
    }
    else{
        printf("No profit, no loss\n"); // Print if there's no profit or loss
    }

    return 0;
}
Sample Input
Sample Output

100 120

Profit: 20.00

150 120

Loss: 30.00

100 100

No profit, no loss

Previous3.1 Conditional StatementNext3.3 Logical Operator

Last updated 8 months ago