đŸ’ģ
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
  • ā§Ē.ā§§.⧍ āύāĻŋāĻŽā§āύ⧋āĻ•ā§āϤ āϧāĻžāϰāĻž āϗ⧁āϞ⧋āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻĒāĻĻ āĻĒā§āϰāĻĻāĻ°ā§āĻļāύ āĻ•āϰāĨ¤ (ā§Ŧ)
  • āϏāĻŽāĻžāϧāĻžāύ
  • [2] 1, 2, 3, 4, ........., N
  • [3] 1, 3, 5, 7, ........., N
  • [4] 2, 4, 6, 8, ........., N
  • [5] 10, 20, 30, 40, ........., N
  • [6] N, N-1, N-2, ........., 4, 3, 2, 1
  • [7] 1, 1, 2, 3, 5, 8, 13, 21, 34, ........., N [āĻĢāĻŋāĻŦā§‹āύāĻžāĻšā§āϚāĻŋ āϏāĻŋāϰāĻŋāϜ]
  1. Solution
  2. 4: Loop

4.1.2 Print Sequence

ā§Ē.ā§§.⧍ āύāĻŋāĻŽā§āύ⧋āĻ•ā§āϤ āϧāĻžāϰāĻž āϗ⧁āϞ⧋āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻĒāĻĻ āĻĒā§āϰāĻĻāĻ°ā§āĻļāύ āĻ•āϰāĨ¤ (ā§Ŧ)

  1. [2] 1, 2, 3, 4, ........., N

    1. [2.1] 1, 2, 3, 4, ........., 100 (Similar)

    2. [2.2] ā§§ āĻĨ⧇āϕ⧇ ā§§ā§Ļā§Ļ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ (Similar)

  2. [3] 1, 3, 5, 7, ........., N

    1. [3.1] 1, 3, 5, 7, ........., 101 (Similar)

  3. [4] 2, 4, 6, 8, ........., N

    1. [4.1] 2, 4, 6, 8, ........., 100 (Similar)

    2. [4.2] ā§§ āĻĨ⧇āϕ⧇ ā§§ā§Ļā§Ļ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϏāĻŦ āĻœā§‹ā§œ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ (Similar)

  4. [5] 10, 20, 30, 40, ........., N

    1. [5.1] 10, 20, 30, ......, 100 (Similar)

  5. [6] N, N-1, N-2, ........., 4, 3, 2, 1

    1. [6.1] N, N-2, N-4, ........., 8, 6, 4, 2 (Similar)

    2. [6.2] N, N-2, N-4, ........., 7, 5, 3, 1 (Similar)

  6. [7] 1, 1, 2, 3, 5, 8, 13, 21, 34, ........., N [āĻĢāĻŋāĻŦā§‹āύāĻžāĻšā§āϚāĻŋ āϏāĻŋāϰāĻŋāϜ]

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

[2] 1, 2, 3, 4, ........., N

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

10

1 2 3 4 5 6 7 8 9 10

5

1 2 3 4 5

[2.1] 1, 2, 3, 4, ........., 100 (Similar)

[2.2] ā§§ āĻĨ⧇āϕ⧇ ā§§ā§Ļā§Ļ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    n = 100;
    for(i = 1; i <= n; i++){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

[3] 1, 3, 5, 7, ........., N

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i += 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

11

1 3 5 7 9 11

51

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51

[3.1] 1, 3, 5, 7, ........., 101 (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    n = 101;
    for(i = 1; i <= n; i += 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101

[4] 2, 4, 6, 8, ........., N

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = 2; i <= n; i += 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

10

2 4 6 8 10

50

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50

[4.1] 2, 4, 6, 8, ........., 100 (Similar)

[4.2] ā§§ āĻĨ⧇āϕ⧇ ā§§ā§Ļā§Ļ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϏāĻŦ āĻœā§‹ā§œ āϏāĻ‚āĻ–ā§āϝāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĨ¤ (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    n = 100;
    for(i = 2; i <= n; i += 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100

[5] 10, 20, 30, 40, ........., N

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = 10; i <= n; i += 10){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

100

10 20 30 40 50 60 70 80 90 100

200

10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200

[5.1] 10, 20, 30, ......, 100 (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    n = 100;
    for(i = 10; i <= n; i += 10){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

10 20 30 40 50 60 70 80 90 100

[6] N, N-1, N-2, ........., 4, 3, 2, 1

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = n; i >= 1; i--){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

10

10 9 8 7 6 5 4 3 2 1

20

20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

[6.1] N, N-2, N-4,........., 8, 6, 4, 2 (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = n; i >= 2; i -= 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

20

20 18 16 14 12 10 8 6 4 2

40

40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2

[6.2] N, N-2, N-4,........., 7, 5, 3, 1 (Similar)

#include<stdio.h>
int main(){
    int n, i;
    
    scanf("%d", &n);
    for(i = n; i >= 1; i -= 2){
        printf("%d ", i);
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

21

21 19 17 15 13 11 9 7 5 3 1

41

41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1

[7] 1, 1, 2, 3, 5, 8, 13, 21, 34, ........., N [āĻĢāĻŋāĻŦā§‹āύāĻžāĻšā§āϚāĻŋ āϏāĻŋāϰāĻŋāϜ]

#include<stdio.h>
int main(){
    int n, a = 1, b = 1, c;
    
    scanf("%d", &n);
    
    printf("%d %d ", a, b);
    while( a + b <= n ){
        c = a + b;
        printf("%d ", c);
        a = b;
        b = c;
    }
    printf("\n");

    return 0;
}

Sample Input Output:

Input
Output

233

1 1 2 3 5 8 13 21 34 55 89 144 233

2000

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597

Previous4.1.1 Loop (Repetition)Next4.1.3 Summation of Series

Last updated 8 months ago