Computer Science, asked by diyab0416, 1 year ago

program to print multiples of 5 using do while loop

Answers

Answered by subhomita200426
3
class multiple

{

void display()

{

longint sum=0,i,n; clrscr();

printf("\n Please Give The Value of N: ");

scanf("%ld",&n);

for(i=1;i<=n;i++) { printf("\n 5 * %ld = %ld",i,5*i);

}

getch();

}

OUTPUT

N: 5 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25

diyab0416: what is getch?
diyab0416: i think u have used for?
diyab0416: for loop*
Answered by Anonymous
2

The program given here prints the first 10 multiples of 5. You can modify it accordingly.

int multiplesFound = 0; //track how many multiples found

int currentNumber = 1; //start checking at 1

do {

if(currentNumber % 5 == 0) {

multiplesFound++;

System.out.println("Found multiple of 5: " + currentNumber);

}

currentNumber++;

} while(multiplesFound<10);

Hope it helps :)

Similar questions