Continue in For Loop in C Programming

Continue in for loop in C Programming, step by step guide with an easy explanation and detailed source code.

Introduction: Continue in For Loop in C Programming

In real life we have a scenario where we need to execute the loops from the start.  For the C Programming has “Continue” Feature. Let’s see how to use that.

Continue statement is used to re-execute the loop from the start. It’s like we initialized the loop again.

It will be difficult to explain in words. Let’s watch the video. In this video, we will see how to print the multiplication table till we want it.

It’s gonna be super fun to learn the continue feature of C Programming.

This blog demonstrates Decrements in a loop in C Programming. To know more about C Programming and it’s history please read this blog first “C Programming Complete Guide 2020

You can watch the video over here which explains the blog in simple video with VFX animation.

Example:

Just like BREAK statement we have CONTINUE statement.

Suppose you want to print the multiplication table. Like this. I guess you have done this many times in school.

Well, let’s write the program for this.

Declaring Variables in C Program

Well, let’s write the program for this.

Here, we will declare 3 variables i, input and result.

main()
{
    int i, input, result;
}

 We will declare one more variable “response” as a character like this.

main()
{
    int i, input, result; 
    char response;
}

We have printf statements, followed by the scanf statement to accept user input. To make it more friendly we will add a few statements using printf.

main()
{
    int i, input, result; 
    char response;
    printf("Execute Multiplication program\n");
    printf("Enter number : ");
    scanf("%d", &input);
}

Now your program will be more user-friendly to understand the user.

Business Logic to Continue in For Loop in C Programming

Then we will write FOR loop.

Inside FOR loop, we will calculate the multiplication like this…

main()
{
    int i, input, result; 
    char response;
    printf("Execute Multiplication program\n");
    printf("Enter number : ");
    scanf("%d", &input);
    for(i=1; i<=10;i++)
    {
	
    }
}

print using printf statement to display the result. 

main()
{
    int i, input, result; 
    char response;
    printf("Execute Multiplication program\n");
    printf("Enter number : ");
    scanf("%d", &input);
    for(i=1; i<=10;i++)
    {
        result = input * i;
        printf("%d * %d = %d\n",input,i,result);
    }
}

We will display the print with the value of i , input and then result. Just like we used to write in our home workbooks.

Just execute it.

Output : 

Build and Run 

Continue in For Loop in C Programming output

3 important parts of any loop

As you know there are 3 important parts of any loop,

  1. 1st is an initialization,
  2. second is condition and
  3. third is the increment.

When you change any of the parameter’s behaviors, the loop changes.

How to view all topics on C Programming

Watch full programming series on Amazon Prime free with Amazon Prime Membership.

Amazon Prime link for the USA: https://www.amazon.com/dp/B07WFYJW6G

Amazon Prime link for the UK: https://www.amazon.co.uk/dp/B07WFYQZ1G

For Other Countries: To watch C Programming Content in another country, please visit the URL:https://newtum.com/course-details/c-programming-online

Frequently Asked question about 

What is a continue statement in C?

Continue is also a loop control statement just like the break statement. continue statement is opposite to that of a break statement.

Facebook Comments
(Visited 5 times, 1 visits today)

Leave A Comment

Your email address will not be published. Required fields are marked *