You should just wrap your code inside a for loop:
#include <stdio.h>
int main() {
int A, B;
char Y = 'Y', N = 'N', C;
for (;;) { // same as while(1)
printf("Enter value 1: ");
if (scanf("%i", &B) != 1)
break;
printf("\nEnter value 2: ");
if (scanf("%i", &A) != 1)
break;
printf("%i + %i = %i\n", A, B, A + B);
printf("\n\nAdd again? Y or N\n");
// note the initial space to skip the pending newline and other whitespace
if (scanf(" %c", &C) != 1 || C != Y)
break;
}
printf("PROGRAM USE ENDED.\n");
return 0;
}
Answer from chqrlie on Stack OverflowGeeksforGeeks
geeksforgeeks.org โบ c language โบ continue-in-c
Continue Statement in C - GeeksforGeeks
If the condition is true, the program control will jump to the start of the loop and all the statements below the continue will be skipped. Steps 1 and 2 will be repeated till the end of the loop. The flowchart of the continue can be constructed using the understanding of the continue we got from above. ... #include <stdio.h> int main() { int n = 1; // Loop from 1 to 10 while (n <= 10) { // If the number is even, skip iteration to avoid printing it if (n % 2 == 0) { n++; continue; } printf("%d ", n); n++; } return 0; }
Published ย October 17, 2025
TutorialsPoint
tutorialspoint.com โบ cprogramming โบ c_continue_statement.htm
Continue Statement in C
The continue statement is used to skip the execution of the rest of the statement within the loop in the current iteration and transfer it to the next loop iteration. It can be used with all the C language loop constructs (while, do while, and for).
c - How to insert a continue statement inside an if statement - Stack Overflow
My code is below. I am using C language. I want to repeat the action from the start if the user types Y but I am confused how can I make that happen. I tried to look for a solution but the results ... More on stackoverflow.com
Is it possible to use continue in conditional operator? in c language - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... No it's not possible, because continue is not an expression, and all parts of a conditional operator must also be expressions. Use an if statement... More on stackoverflow.com
Continue a if statement in C++ - Stack Overflow
Instead, you can save this post to reference later. ... By continuing to use this website, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. By exiting this window, default cookies will be accepted. More on stackoverflow.com
Reddit - The heart of the internet
Reddit is where millions of people gather for conversations about the things they care about, in over 100,000 subreddit communities. More on reddit.com
Videos
Learn Programming Technique C to Master Skills - Loop with ...
18:24
Break And Continue Statement In C++ Programming | C++ Programming ...
05:07
Continue Statement in C Programming Language Video Tutorials - YouTube
04:26
14. Continue Statement in C language - YouTube
05:31
break and continue statements | C Programming Tutorial - YouTube
#14 : break and continue in C | C Programming for Beginners
Learn C
learnc.net โบ home โบ learn c programming โบ c continue
An Essential Guide to C continue Statement By Examples
April 13, 2025 - The continue statement works like a shortcut to the end of the loop body. To continue statement includes the continue keyword with a semicolon (;): ... In practice, you often use the continue statement with an if statement to specify a condition for skipping the current iteration:
Top answer 1 of 2
3
You should just wrap your code inside a for loop:
#include <stdio.h>
int main() {
int A, B;
char Y = 'Y', N = 'N', C;
for (;;) { // same as while(1)
printf("Enter value 1: ");
if (scanf("%i", &B) != 1)
break;
printf("\nEnter value 2: ");
if (scanf("%i", &A) != 1)
break;
printf("%i + %i = %i\n", A, B, A + B);
printf("\n\nAdd again? Y or N\n");
// note the initial space to skip the pending newline and other whitespace
if (scanf(" %c", &C) != 1 || C != Y)
break;
}
printf("PROGRAM USE ENDED.\n");
return 0;
}
2 of 2
1
There are a lot of errors in your program. Syntax error: please resolve it on your own. There is no need for Y and N to be declared as character, you can use them directly as they are not storing any value. NOW, there is no need for continue you can use while loop. I have resolved your problem. Please take a look
Also, you are using a lot of scanf so there is an input buffer, a simple solution to it is using getchar() which consumes the enter key spaces.
#include <stdio.h>
int main()
{
int A, B;
char C = 'Y';
while (C == 'Y')
{
printf("Enter value 1: ");
scanf("%i", &B);
printf("\nEnter value 2");
scanf("%i", &A);
printf("= %i\n", A + B);
getchar();
printf("\n\nAdd again? Y or N\n");
scanf("%c", &C);
}
if (C == 'N')
{
printf("PROGRAM USE ENDED.");
}
else
{
printf("Error.");
}
}
Cppreference
en.cppreference.com โบ w โบ cpp โบ language โบ continue.html
continue statement - cppreference.com
June 19, 2024 - The continue statement causes a jump, as if by goto to the end of the loop body (it may only appear within the loop body of for, range-for, while, and do-while loops). ... #include <iostream> int main() { for (int i = 0; i < 10; ++i) { if (i != 5) continue; std::cout << i << ' '; // this statement ...
Programiz
programiz.com โบ c-programming โบ c-break-continue-statement
C break and continue
Become a certified C programmer. Try Programiz PRO! ... The break statement ends the loop immediately when it is encountered. Its syntax is: ... The break statement is almost always used with if...else statement inside the loop.
Unstop
unstop.com โบ home โบ blog โบ continue statement in c | working, use & more (+examples)
Continue Statement In C | Working, Use & More (+Examples)
May 28, 2024 - If the statement condition is false, meaning the value of i is even, then the if-block is skipped. And the printf() statement after that is executed, which displays the value of i. Here, the %d format specifier indicates an integer value, and the newline escape sequence (\n) shifts the cursor to the next line so that the next output is printed in a new line. As shown in the output for the example of the continue statement in C, this loop continues printing even numbers to the console, skipping odd numbers.
BeginnersBook
beginnersbook.com โบ 2014 โบ 01 โบ c-continue-statement
C โ continue statement with example
September 23, 2017 - When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration. ... #include <stdio.h> int main() { for (int j=0; j<=8; j++) { if (j==4) { /* The continue ...
Dremendo
dremendo.com โบ c-programming-tutorial โบ c-break-and-continue-statement
break and continue Statement in C | Dremendo
In the above example, we want to exit from the loop when the value of i is equal to 10. So, we have used a break statement inside the body of if statement which executes when the given condition is true, and the loop terminates. Nested for Loop: We can also use break statement while working with nested loops.
W3Schools
w3schools.com โบ c โบ c_break_continue.php
C Break and Continue
The break statement can also be used to jump out of a loop. ... The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
Tutorial Gateway
tutorialgateway.org โบ continue-statement-in-c
Continue Statement in C Programming
April 2, 2025 - And we want to skip executing the second 5 lines (statement6 โstatement10) when a certain condition is True, or else it has to execute all the 10 lines inside the loop. In these situations, we place the condition after the 5th statement, followed by this continue statement. If the condition is True, then it will stop executing statements 6 to 10.
Stack Overflow
stackoverflow.com โบ questions โบ 74589547 โบ continue-a-if-statement-in-c
Continue a if statement in C++ - Stack Overflow
July 23, 2025 - Copyif (foo()) { if (!bar()) { ... } } ... Nothing to say about this question in particular but the best way to reduce indentation is to split your code into separate functions. ... Save this answer. Show activity on this post. You can replace the true-branch statement by a call to a lambda function from which you return, if you want something like that:
GNU
gnu.org โบ software โบ c-intro-and-ref โบ manual โบ html_node โบ continue-Statement.html
continue Statement (GNU C Language Manual)
for (;*p; ++p) { /* Exit if we have reached a newline. */ if (*p == '\n') break; /* Pay no attention to spaces. */ if (*p != ' ') { /* Operate on the next character. */ โฆ } } The advantage of using continue is that it reduces the depth of nesting. Contrast continue with the break statement.
Sololearn
sololearn.com โบ en โบ Discuss โบ 2441763 โบ how-to-make-python-continue-after-if-statement
How to make Python continue after if statement | Sololearn: Learn to code for FREE!
August 12, 2020 - "". join["w" if c in["l", "r"] else c for c in list(message)] https://code.sololearn.com/cP8mz8YnWilg/?ref=app ... A bit late with my post, but it shows a simplified version of the code. There are 2 conditional statements to check if the desired characters are in the input string.