đŸ’ģ
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
  • āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ (ā§Ē)
  • āϏāĻŽāĻžāϧāĻžāύ
  • [1.1] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āĻļā§‚āĻ¨ā§āϝ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [1.2] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āϧāύāĻžāĻ¤ā§āĻŽāĻ• āύāĻž āĻ‹āĻŖāĻžāĻ¤ā§āĻŽāĻ• āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [1] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āĻļā§‚āĻ¨ā§āϝ āύāĻž āϧāύāĻžāĻ¤ā§āĻŽāĻ• āύāĻž āĻ‹āĻŖāĻžāĻ¤ā§āĻŽāĻ• āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [2] āĻŦ⧟āϏ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻāĻ•āϜāύ āĻŦā§āϝāĻžāĻ•ā§āϤāĻŋ āĻ­ā§‹āϟāĻžāϰ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  • [3] āĻŦ⧟āϏ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āϚāĻžāĻ•āϰāĻŋāϰ āφāĻŦ⧇āĻĻāύ āĻ•āϰāĻžāϰ āϝ⧋āĻ—ā§āϝ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āύāĻŋāĻ°ā§āϧāĻžāϰāĻŋāϤ āĻŦ⧟āϏāϏ⧀āĻŽāĻž ā§§ā§Ž āĻĨ⧇āϕ⧇ ā§Šā§Ģ)
  • [4] āĻĻ⧁āχāϟāĻŋ āϜāϟāĻŋāϞ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤
  1. Solution
  2. 3: Conditional Statements

3.1 Conditional Statement

āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ (ā§Ē)

  1. āĻļā§‚āĻ¨ā§āϝ, āϧāύāĻžāĻ¤ā§āĻŽāĻ•, āĻ‹āĻŖāĻžāĻ¤ā§āĻŽāĻ• - āϏāĻ‚āĻ–ā§āϝāĻžāϰ āϚāĻŋāĻšā§āύ āύāĻŋāĻ°ā§āϪ⧟

    1. [1.1] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āĻļā§‚āĻ¨ā§āϝ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (Similar)

    2. [1.2] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āϧāύāĻžāĻ¤ā§āĻŽāĻ• āύāĻž āĻ‹āĻŖāĻžāĻ¤ā§āĻŽāĻ• āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (Similar)

    3. [1] āĻāĻ•āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖāϏāĻ‚āĻ–ā§āϝāĻž āĻļā§‚āĻ¨ā§āϝ āύāĻž āϧāύāĻžāĻ¤ā§āĻŽāĻ• āύāĻž āĻ‹āĻŖāĻžāĻ¤ā§āĻŽāĻ• āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

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

  3. [3] āĻŦ⧟āϏ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āϚāĻžāĻ•āϰāĻŋāϰ āφāĻŦ⧇āĻĻāύ āĻ•āϰāĻžāϰ āϝ⧋āĻ—ā§āϝ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āύāĻŋāĻ°ā§āϧāĻžāϰāĻŋāϤ āĻŦ⧟āϏāϏ⧀āĻŽāĻž ā§§ā§Ž āĻĨ⧇āϕ⧇ ā§Šā§Ģ)

  4. [4] āĻĻ⧁āχāϟāĻŋ āϜāϟāĻŋāϞ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

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

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

#include<stdio.h>
int main(){
    int a = 0; // Output => Zero
    //int a = 1; // No Output
    
    if( a == 0 ){ // Testing Equlity Operator [==]
        printf("Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 0; // Output => Zero
    //int a = 1; // Output => Not Zero
    
    if( a == 0 ){ // Testing Equlity Operator [==]
        printf("Zero\n");
    }
    if( a != 0 ){ // Testing Not Equlity Operator [!=]
        printf("Not Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 0; // Output => Zero
    //int a = 1; // Output => Not Zero
    
    if( a == 0 ){
        printf("Zero\n");
    }
    else{ // Else block will execute when (a == 0) is false
        printf("Not Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 0; // Output => Zero
    //int a = 1; // Output => Not Zero
    
    if( a ){ // if evaluate 0 as FALSE and non-zero value as TRUE
    // This block will execute when the value of a is non-zero
        printf("Not Zero\n");
    }
    else{
    // This block will execute when the value of a is 0
        printf("Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 0; // Output => Zero
    //int a = 1; // Output => Not Zero
    
    // Logical NOT Operator
    if( !a ){ // when a=0, it means a is FALSE, !a means TRUE
    // This block will execute when the value of a is 0
        printf("Zero\n");
    }
    else{
    // This block will execute when the value of a is non-zero
        printf("Not Zero\n");
    }
    
    return 0;
}

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

#include<stdio.h>
int main(){
    int a = 5; // Output => Positive
    //int a = -5; // Output => Negative
    //int a = 0; // No Output
    
    if( a > 0 ){ // Testing Grater Then Operator [>]
        printf("Positive\n");
    }
    if( a < 0 ){ // Testing Less Then Operator [<]
        printf("Negative\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 5; // Output => Positive
    //int a = -5; // Output => Negative
    //int a = 0; // Output => Negative
    
    if( a > 0 ){ // Testing Grater Then Operator [>]
        printf("Positive\n");
    }
    else{ // Else block will execute when (a > 0) is false
        printf("Negative\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a = 5; // Output => Positive
    //int a = -5; // Output => Negative
    //int a = 0; // Output => Positive
    
    if( a >= 0 ){ // Testing Grater Then or Equal Operator [>=]
        printf("Positive\n");
        // Zero is neither Position nor Negative
        // So This Solution is not perfect
    }
    else{ // Else block will execute when (a > 0) is false
        printf("Negative\n");
    }
    
    return 0;
}

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

#include<stdio.h>
int main(){
    int num = 5; // Output => Positive
    //int num = -5; // Output => Negative
    //int num = 0; // Output => Zero
    
    if( num > 0 ){ // Testing Grater Then Operator [>]
        printf("Positive\n");
    }
    if( num < 0 ){ // Testing Less Then Operator [<]
        printf("Negative\n");
    }
    if( num == 0 ){ // Testing Equlity Operator [==]
        printf("Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int num = 5; // Output => Positive
    //int num = -5; // Output => Negative
    //int num = 0; // Output => Zero
    
    if( num > 0 ){ // Testing Grater Then Operator [>]
        printf("Positive\n");
    }
    else if( num < 0 ){ // Testing Less Then Operator [<]
        printf("Negative\n");
    }
    else if( num == 0 ){ // Testing Equlity Operator [==]
        printf("Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int num = 5; // Output => Positive
    //int num = -5; // Output => Negative
    //int num = 0; // Output => Zero
    
    if( num > 0 ){ // Testing Grater Then Operator [>]
        printf("Positive\n");
    }
    else if( num < 0 ){ // Testing Less Then Operator [<]
        printf("Negative\n");
    }
    else{
    // This else block will execute when both previous conditions are false
        printf("Zero\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int num = 5; // Output => Positive
    //int num = -5; // Output => Negative
    //int num = 0; // Output => Zero
    
    if( num == 0 ){ // Testing Equlity Operator [==]
        printf("Zero\n");
    }
    else{
        if( num > 0 ){ // Testing Grater Then Operator [>]
            printf("Positive\n");
        }
        //else if( num < 0 ){ // Testing Less Then Operator [<]
        else{
            printf("Negative\n");
        }
    }
    
    return 0;
}
Sample Input
Sample Output

5

Positive

-3

Negative

0

Zero

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

Test Voting Eligibility 1 (only if solution)

#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // No Output
 
    if(age > 18){
        printf("Eligible to Vote\n");
    }
    if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age == 18){
        printf("Eligible to Vote\n");
    }
    if(age > 18){
        printf("Eligible to Vote\n");
    }
    if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age == 18 || age > 18){
        printf("Eligible to Vote\n");
    }
    if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age >= 18){
        printf("Eligible to Vote\n");
    }
    if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}

Test Voting Eligibility 2 (if else solution)

#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age >= 18){
        printf("Eligible to Vote\n");
    }
    else if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age >= 18){
        printf("Eligible to Vote\n");
    }
    else{
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
#define VOTE_AGE 18 // Define VOTE_AGE macro
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if( age >= VOTE_AGE ){
        printf("Eligible to Vote\n");
    }
    else{
        printf("Not Eligible to Vote\n");
    }
    
    return 0;
}

Test Voting Eligibility 3 (alternative solution)

#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age < 18){
        printf("Not Eligible to Vote\n");
    }
    else{
        printf("Eligible to Vote\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Voter
    //int age = 15; // Output => Not Voter
    //int age = 18; // Output => Voter
 
    if(age <= 17){
        printf("Not Eligible to Vote\n");
    }
    else{
        printf("Eligible to Vote\n");
    }
    
    return 0;
}

[3] āĻŦ⧟āϏ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āϚāĻžāĻ•āϰāĻŋāϰ āφāĻŦ⧇āĻĻāύ āĻ•āϰāĻžāϰ āϝ⧋āĻ—ā§āϝ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤ (āύāĻŋāĻ°ā§āϧāĻžāϰāĻŋāϤ āĻŦ⧟āϏāϏ⧀āĻŽāĻž ā§§ā§Ž āĻĨ⧇āϕ⧇ ā§Šā§Ģ)

#include<stdio.h>
int main(){
    int age = 20; // Output => Eligible to apply
    //int age = 15; // Output => Not Eligible to apply
    //int age = 38; // Output => Not Eligible to apply
 
    if(age >= 18){ // Testing Grater Then or Equal Operator [>=]
        if( age <= 35 ){ // Testing Less Then or Equal Operator [<=]
            printf("Eligible to apply\n");
        }
        else{
            printf("Not eligible to apply\n");
        }
    }
    else{
        printf("Not eligible to apply\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Eligible to apply
    //int age = 15; // Output => Not Eligible to apply
    //int age = 38; // Output => Not Eligible to apply
 
    if(age >= 18 && age <= 35){ // Testing Logical AND Operator [&&]
    // Print "Eligible to apply" if the age is between 18 and 35 inclusive
        printf("Eligible to apply\n");
    }
    else{
    // Print "Not Eligible to apply" if the age is outside the range
        printf("Not eligible to apply\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Eligible to apply
    //int age = 15; // Output => Not Eligible to apply
    //int age = 38; // Output => Not Eligible to apply
 
    if(age <= 18){ // Testing Less Then or Equal Operator [<=]
        printf("Not eligible to apply\n");
    }
    else if( age >= 35 ){ // Testing Grater Then or Equal Operator [>=]
        printf("Not eligible to apply\n");
    }
    else{
        printf("Eligible to apply\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int age = 20; // Output => Eligible to apply
    //int age = 15; // Output => Not Eligible to apply
    //int age = 38; // Output => Not Eligible to apply
 
    if(age <= 18 || age >= 35){ // Testing Logical OR Operator [||]
        printf("Not eligible to apply\n");
    }
    else{
        printf("Eligible to apply\n");
    }
    
    return 0;
}
Sample Input
Sample Output

20

Eligible to apply

15

Not Eligible to apply

38

Not Eligible to apply

[4] āĻĻ⧁āχāϟāĻŋ āϜāϟāĻŋāϞ āϏāĻ‚āĻ–ā§āϝāĻž āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#include<stdio.h>
int main(){
    int a1 = 0, b1 = 1, a2 = 0, b2 = 1; // Output => Equal
    //int a1 = 1, b1 = 1, a2 = 0, b2 = 0; // Output => Not Equal
    
    if( a1 == a2 ){
        if( b1 == b2 ){
            printf("Equal\n");
        }
        else{
            printf("Not Equal\n");
        }
    }
    else{
        printf("Not Equal\n");
    }
    
    return 0;
}
#include<stdio.h>
int main(){
    int a1 = 0, a1 = 1, a2 = 0, b2 = 1; // Output => Equal
    //int a1 = 1, b1 = 1, a2 = 0, b2 = 0; // Output => Not Equal
    
    if( a1 == a2 && b1 == b2 ){
        printf("Equal\n");
    }
    else{
        printf("Not Equal\n");
    }
    
    return 0;
}
Sample Input
Sample Output

3 4 3 4

The complex numbers are equal

5 6 5 7

The complex numbers are not equal

Previous3: Conditional StatementsNext3.2 Relational Operator

Last updated 8 months ago