Below is the link to my hw worksheet.
http://www.scribd.com/doc/55604388
keerthi_CS
Tuesday, May 17, 2011
Wednesday, January 19, 2011
C.S - 11
C - 1 (H.W)
class linear_search
{
public static void main (String args [])
{
int a [] = { 8, 19, 61, 37,24,13, 9, 10 }
int i, f=0, pos = 0, s=13;
for (i=0; i<8, i++)
{
if ( a[i]==s)
{
f=1;
pos = i+1;
}
}
if (f>0)
{
System.out.println ("The element is found at position " + pos);
}
else
{
System.out.println (" Element is not present in given list.");
}
}
}
class linear_search
{
public static void main (String args [])
{
int a [] = { 8, 19, 61, 37,24,13, 9, 10 }
int i, f=0, pos = 0, s=13;
for (i=0; i<8, i++)
{
if ( a[i]==s)
{
f=1;
pos = i+1;
}
}
if (f>0)
{
System.out.println ("The element is found at position " + pos);
}
else
{
System.out.println (" Element is not present in given list.");
}
}
}
Thursday, December 16, 2010
C.S Holiday Homework
Sir below is just the code (but not the algorithm) and it is only half done. I was not sure what the holiday hw meant, and you didn't give any example also sir. But then I tried researching and understanding something to a certain extent with the class notes and below is what I have been able to so far. Please check.
CODE:
class CalculatorOperations
{
public static void main (Strings [ ] args)
{
System.out.println (“Calculation Section with operations:”);
System.out.println (“Enter the two integers”);
int value1;
int value2;
void get data (int a; int b)
{
value1 = a;
value2 = b;
}
System.out.println (“Enter operation ( + - * / ) : ”);
char operator;
void get data (char o)
{
char operator = o;
}
int calculate result ( );
{
int result;
if (operator = “ + ”)
{
result = value1 + value2;
}
else if (operator = “ - ”)
{
result = value1 - value2;
}
else if (operator = “ * ”)
{
result = value1 * value2;
}
else if (operator = “ / ” && value2 != 0)
{
result = value1 / value2;
}
else
{
System.out.println (“unknown operator” + operator + “Please try again.”);
}
System.out.println (“ The result is: ” +result);
}
}
}
Subscribe to:
Comments (Atom)
