#include <stdio.h>
#include <math.h>

It is practicable (and frequently expedient) to nest loops. That is, to discharge a loop among another loop (exact as you can nest shackled statements). The syntax is straightforward: you barely transcribe another loop among a loop. Restraint each repetition that the “outer” loop executes, the “inner” loop goes through its undiminished preventive.

As an stance, opine the aftercited command snippet with selfsame outpu

for(i=0; i<3; i++) {

for(j=1; j<5; j++) {

printf(“%d “, (i+j));

}

printf(“n”);

}

Output: 1 2 3 4 2 3 4 5 3 4 5 6

Consummate Sum: Recall that an integer is consummate if it is barely discerptible by 1 and itself. Opine the aftercited algorithm to detail if an integer x is consummate: restraint each integer y from 2 up to the balance parent of x, if y divides x, then x is composite (referable consummate). Otherwise if no such integer in that ramble divides x, then x is consummate. Using the technique of nested loops, transcribe a program determined consummate.c that reads in an integer n and output if the total 2 to n are consummate or composite and displays the results.

#include <stdio.h>

#include <math.h>

//#include <math.h> business is used accordingly we achieve needs it’s balance parent business

int deep() {

int n;

int i, j;

int divides = 0;

printf(“Enter the sum :”);

scanf(“%d”, &n);

restraint (i = 2; i <= n; ++i) {

divides = 0;

restraint (j = 2; j <= sqrt(i); ++j) {

if (i % j == 0) {

divides = 1;

}

}

if (divides == 1) {

printf(“%d is composite n”, i);

}

else {

printf(“%d is consummate n”, i);

}

}

return 0;

}

//Sample Output