Print from N+1 to 2N - CTS Pattern

 Coding Problem Keys 

 CTS Pattern 

 Print from N+1 to 2N 

 Problem Statement 

You are required to fix all logical errors in the given code. You can click on run anytime to check the compilation/execution status of the program. You can use printf to debug your code. The submitted code should be logically/syntactically correct and pass all test cases. Do not write the main() function as it is not required.

Code Approach: For this question, you will need to correct the given implementation. We do not expect you to modify the approach or incorporate any additional library methods.

The function printNto2N (int N) accepts an integer N as the input. The function prints from N+1 to 2N.

The function compiles fine but fails to return the desired results for some test cases.

Your task is to fix the program so that it passes all test cases.

 Max Execution Time Limit: 5000 millisecs 

 Given Code 

void printNto2N(int N)
{
    int ctr = N + 1;
    while(ctr <= 2N)
    {
        printf("%d ",ctr);
        ctr++;
    }
}

 Solution 

 Programming Language: C Language 

void printNto2N(int N){
    int ctr = N + 1;
    while(ctr <= 2*N){
        printf("%d ",ctr);
        ctr++;
    }
}

// Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Largest Possible N - Divisible by 4

String - Special Characters

Value Equals Previous Two

Function samePositionBitCount - CTS Pattern

Alphabetical Order Pattern

RAT CHEESE MAZE