(Knock! Knock!)
Who's there?
(a very long pause..)
Java
------------------------------------------------------------
C: I'll tell you a joke.
Java: Ok.
C:(points to NULL) Look.
Java:(Frowns) I don't get it.
------------------------------------------------------------
Here's a program my friend came up with, when I asked him to find the average of 5 numbers using any loop.
Hope you enjoyed them!
Who's there?
(a very long pause..)
Java
------------------------------------------------------------
C: I'll tell you a joke.
Java: Ok.
C:(points to NULL) Look.
Java:(Frowns) I don't get it.
------------------------------------------------------------
Here's a program my friend came up with, when I asked him to find the average of 5 numbers using any loop.
public class Average { public static void main() { int a[] = new int[5]; a[0] = 73; a[1] = 42; a[2] = 15; a[3] = 9; a[4] = 1; int b=0; int sum=0; int x=0; for( x = 0 ; x<5 ; x++ ) { sum = a[0] + a[1] + a[2] + a[3] + a[4]; } b = sum / 5; System.out.println("The average is: " + b); } }
Hope you enjoyed them!