Program Console Vignaankosh.com
Execution Panel
Console is empty.
Count prime pairs satisfying conditions (for loop) is an interactive C dry run visualizer from the Nested programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
int isPrime(int n) { int i;
if(n < 2) return 0;
for(i = 2; i * i <= n; i++)
if(n % i == 0) return 0;
return 1;
}
int main() {
int n, p;
printf("Enter n: ");
scanf("%d", &n);
printf("Twin prime pairs (p, p+2) where both are prime:\n");
int twin_count = 0;
for(p = 2; p <= n - 2; p++) {
if(isPrime(p) && isPrime(p + 2)) {
printf("(%d, %d) ", p, p + 2);
twin_count++;
}
}
printf("\nTotal twin prime pairs: %d\n", twin_count);
printf("\nPrime pairs (p, p+4) where both are prime:\n");
int cousin_count = 0;
for(p = 2; p <= n - 4; p++) {
if(isPrime(p) && isPrime(p + 4)) {
printf("(%d, %d) ", p, p + 4);
cousin_count++;
}
}
printf("\nTotal cousin prime pairs: %d\n", cousin_count);
return 0;
}