Вы находитесь на странице: 1из 4

Understanding Computer Applications (Iteration Through Loops) www.kishorepandit.

com
Solutions to the questions in book. Page 1 of 4

Solution to Q4 public class IX


{ public static void main(String args[])
/* Display first 10 terms of the series { int n=2;
1 4 9 16... for(int i=1; i<=10; i++)
*/ { n*=2;
public class IX System.out.println( n );
{ public static void main(String args[]) }// i
{ for(int i=1; i<=10; i++) }//main
{ int n=i*i; }//class
System.out.println( n );
}// i
}//main /* Display first 10 terms of the series
}//class 1.5 3.0 4.5 6.0 ...
*/
public class IX
/* Display first 10 terms of the series { public static void main(String args[])
1 2 4 7 11... { for(double i=1.5; i<=15; i+=1.5)
*/ { System.out.println( i );
public class IX }// i
{ public static void main(String args[]) }//main
{ int n=1; }//class
for(int i=1; i<=10; i++)
{ System.out.println( n );
n+=i; /* Display first 10 terms of the series
}// i 0 7 26 ...
}//main */
}//class public class IX
{ public static void main(String args[])
{
/* Display first 10 terms of the series for(int i=1; i<=10; i++)
3 6 9 12... { int n= (i*i*i)-1;
*/ System.out.println( n );
public class IX }// i
{ public static void main(String args[]) }//main
{ for(int i=1; i<=10; i++) }//class
{ int n=3*i;
System.out.println( n );
}// i
}//main /* Display first 10 terms of the series
}//class 1 9 25 49 ...
*/
public class IX
/* Display first 10 terms of the series { public static void main(String args[])
4 8 16 32... {
*/ for(int i=1; i<=20; i+=2)
Understanding Computer Applications (Iteration Through Loops) www.kishorepandit.com
Solutions to the questions in book. Page 2 of 4

{ int n= (i*i); }//main


System.out.println( n ); }//class
}// i
}//main
}//class /* Display first 10 terms of the series
2 5 10 17...
*/
/* Display first 10 terms of the series public class IX
4 16 36 64 ... { public static void main(String args[])
*/ {
public class IX for(int i=1; i<=10; i++)
{ public static void main(String args[]) { int n= (i*i)+1;
{ System.out.println( n );
for(int i=2; i<=20; i+=2) }// i
{ int n= (i*i); }//main
System.out.println( n ); }//class
}// i
}//main Solution to Q22
}//class /*
1
21
/* Display first 10 terms of the series 321
0 3 8 15 ... 4321
*/ 54321
public class IX */
{ public static void main(String args[]) public class IX
{ { public static void main(String args[])
for(int i=1; i<=10; i++) { for(int i=1; i<=5; i++)
{ int n= (i*i)-1; { for(int j=i; j>=1; j--)
System.out.println( n ); { System.out.print( j );
}// i }// j
}//main System.out.println();
}//class }// i
}//main
}//class
/* Display first 10 terms of the series
24 99 224 355...
*/ /*
public class IX 12345
{ public static void main(String args[]) 1234
{ 123
for(int i=5; i<=50; i+=5) 12
{ int n= (i*i)-1; 1
System.out.println( n ); */
}// i public class IX
Understanding Computer Applications (Iteration Through Loops) www.kishorepandit.com
Solutions to the questions in book. Page 3 of 4

{ public static void main(String args[]) }// i


{ for(int i=5; i>=1; i--) }//main
{ for(int j=1; j<=i; j++) }//class
{ System.out.print( j );
}// j
System.out.println(); /*
}// i 5
}//main 54
}//class 543
5432
54321
/*
54321 */
5432 public class IX
543 { public static void main(String args[])
54 { for(int i=5; i>=1; i--)
5 { for(int j=5; j>=i; j--)
*/ { System.out.print( j );
public class IX }// j
{ public static void main(String args[]) System.out.println();
{ for(int i=1; i<=5; i++) }// i
{ for(int j=5; j>=i; j--) }//main
{ System.out.print( j ); }//class
}// j
System.out.println();
}// i /*
}//main 12345
}//class 2345
345
45
/* 5
13579
1357 */
135 public class IX
13 { public static void main(String args[])
1 { for(int i=1; i<=5; i++)
{ for(int j=i; j<=5; j++)
*/ { System.out.print( j );
public class IX }// j
{ public static void main(String args[]) System.out.println();
{ for(int i=9; i>=1; i-=2) }// i
{ for(int j=1; j<=i; j+=2) }//main
{ System.out.print( j ); }//class
}// j
System.out.println();
Understanding Computer Applications (Iteration Through Loops) www.kishorepandit.com
Solutions to the questions in book. Page 4 of 4

/* 5
1
22 */
333 public class IX
4444 { public static void main(String args[])
55555 { for(int i=1; i<=5; i++)
{ for(int j=i; j<=5; j++)
*/ { System.out.print( i );
public class IX }// j
{ public static void main(String args[]) System.out.println();
{ for(int i=1; i<=5; i++) }// i
{ for(int j=1; j<=i; j++) }//main
{ System.out.print( i ); }//class
}// j
System.out.println();
}// i /*
}//main 5
}//class 44
333
2222
/* 11111
55555
4444 */
333 public class IX
22 { public static void main(String args[])
1 { for(int i=5; i>=1; i--)
{ for(int j=i; j<=5; j++)
*/ { System.out.print( i );
public class IX }// j
{ public static void main(String args[]) System.out.println();
{ for(int i=5; i>=1; i--) }// i
{ for(int j=1; j<=i; j++) }//main
{ System.out.print( i ); }//class
}// j
System.out.println();
}// i
}//main
}//class

/*
11111
2222
333 [END]
44

Вам также может понравиться