Computer Science, asked by jsathwik6224, 7 months ago

Write a program to print 3,6,9,12....30 using while loop

Answers

Answered by Berseria
36

\huge\mathbb\purple{AnSwEr}

Elements of a Loop are:-

  • Intialisation
  • Test expression
  • Update statement
  • Body of the loop.

Types of loop:-

  • While loop( entry controlled loop)
  • For loop ( entry controlled loop)
  • Do while loop (exit controlled loop)

Syntax of while loop:-

\sf \: initialzation \\ \sf \:  \:  while(test \: expression) \\

{

\sf \: body \: of \: the \: loop \\ \sf \: update \: statement \: \\

}

Required program:-

i = 3

while(i <=30)

{

cout<<"\t <<i ;

i = i +3;

}

hope this helps..

Answered by anindyaadhikari13
10

Question:-

Write a program to display the series using while loop.

3 6 9 12...30

Program:-

class Series

{

public static void main(String args[])

{

int a=3;

while(a<=30)

{

System.out.print(a+" ");

a+=3;

}

}

}

Similar questions