Friday, July 9, 2010

Crazy While loop


People go Crazy some times...im no more exception to that.
Hari n Sangam Raju forced me to write this....CC to Soman Aradhya :)


while loop in java
while (expression) {
statement(s)
}
eg: int noOfKiss=0;
While (isTrishaAlive()){
kisstoHarish(); noOfKiss++;}

coldfusion while loop:

<cfloop condition="myVar eq false">
<cfoutput>i am in while loop
</cfloop>

javascript while loop:

<script type="text/javascript">
var i=0;
while (i<=5)
{
document.write("The number is " + i);
document.write("<br />");
i++;
}
</script>

C while loop:
#include<stdio.h>

main(){

int i = 0;
while (i<5){
printf(" the value of i is %d\n", i);
i = i + 1;
}
}

python while loop:
#!/usr/bin/python

count = 0
while (count < 9):
print 'The count is:', count
count = count + 1

print "Good bye!"

JSP while loop:
<%
int value = 5;

while (value > 0) {
out.println("The value is now " + value-- + ".<BR>");
}
%>

ASP while loop:
<%
Do While thenumber<10
Resonse.Write("Less than 10")
thenumber = thenumber + 1
Loop
%>


JSF while loop:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<ui:repeat value="#{TableBean.perInfoAll}" var="info">
<li>
<h:inputText value="#{info.id}" />
<h:inputText value="#{info.name}" />
</li>
</ui:repeat>

PHP while loop:
$brush_price = 5;
$counter = 10;

echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Quantity</th>";
echo "<th>Price</th></tr>";
while ( $counter <= 100 ) {
echo "<tr><td>";
echo $counter;
echo "</td><td>";
echo $brush_price * $counter;
echo "</td></tr>";
$counter = $counter + 10;
}
echo "</table>";


PERL while loop:
#!/usr/bin/perl

print "content-type: text/html \n\n";

# SET A VARIABLE
$count = 0;

# RUN A WHILE LOOP
while ($count <= 7) {
# PRINT THE VARIABLE AND AN HTML LINE BREAK
print "$count<br />";
# INCREMENT THE VARIABLE EACH TIME
$count ++;
}
print "Finished Counting!";

VB while loop:

Dim counter As Integer = 0
While counter < 20
counter += 1
' Insert code to use current value of counter.
End While
MsgBox("While loop ran " & CStr(counter) & " times")

SQL server2005 while loop:
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT @intFlag
SET @intFlag = @intFlag + 1
END
GO

BASH while loop:
#!/bin/bash
c=1
while [ $c -le 5 ]
do
echo "Welcone $c times"
(( c++ ))
done

KSH while loop:

#!/bin/ksh
c=1
while [[ $c -le 5 ]]; do
echo "Welcome $c times"
(( c++ ))
done

CSH while loop:

#!/bin/csh
c=1
while ( $c <= 5 )
echo "Welcome $c times"
@ c = $c + 1
end

other CSH while loop:
#!/bin/csh
set yname="foo"
while ( $yname != "" )
echo -n "Enter your name : "
set yname = $<
if ( $yname != "" ) then
echo "Hi, $yname"
endif
end


Do you ever heard about "while" loop in programming language?

while loop syntax thelsa

I didnt know what to respond for that



Image source: http://www.webdeveloperjuice.com/wp-content/uploads/2010/03/14_eac33_9_600.jpg