Overnight Programming Challenge
24th -25thSeptember 2011
4:30 p.m.-11:00a.m.
Submit your answers on blog.utkarsh@gmail.com or to any utkarsh member before 11:00 a.m. on 25th September 2011
Q. 1.Write a program to print the following pattern(c/c++/java)?
*
*
*
*
*
Q. 2. What is the output of the following program?
#include <stdio.h>
int main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" , *(a+1), *(ptr-1) );
return 0;
}
Q. 3. What is the output of the following shell script?
#!/bin/bash
num=10
num1=0
num2=1
echo $num1
echo $num2
count=2
while [ $count -le $num ]
do
num3=`expr $num1 + $num2`
echo $num3
num1=$num2
num2=$num3
count=`expr $count + 1`
done
Q. 4. What is the output of the following program?
public class Foo
{
Foo()
{
System.out.print("foo");
}
class Bar
{
Bar()
{
System.out.print("bar");
}
public void go()
{
System.out.print("hi");
}
} /* class Bar ends */
public static void main (String [] args)
{
Foo f = new Foo();
f.makeBar();
}
void makeBar()
{
(new Bar() {}).go();
}
}/* class Foo ends */
Q. 5. Write a program to accept percentage of marks from user and print ‘A’ if it lies between 90-100%, ‘B’ if it lies between 70-90%, ‘C’ if it lies between 60-70%, ‘D’ if it lies between 40-60% and ‘E’ if it is less than 40% using only switch case.
Q. 6. Pretend that in the classic 80's movie back to the Future, it took the clock tower 6 seconds to strike 4 o'clock. How many seconds does it take for the tower to strike 12 o'clock?
Q. 7. The latest release the group Prime Players Three consists of three CDs. Each has a different playing time. Each CD has four tracts and a total playing time of not more than one hour. The four tracks on any one of these CDs each last a prime number of minutes and each one is a different length. Any combination of the three different tracks on any one of the CDs plays for a prime number of minutes. What are the lengths in minutes of the track on these three CDs?
Q. 8. What is the output of the following program?
public abstract class AbstractTest
{
public int getNum()
{
return 45;
}
public abstract class Bar
{
public int getNum()
{
return 38;
}
}
public static void main (String [] args)
{
AbstractTest t = new AbstractTest()
{
public int getNum()
{
return 22;
}
};
AbstractTest.Bar f = t.new Bar()
{
public int getNum()
{
return 57;
}
};
System.out.println(f.getNum() + " " + t.getNum());
}
}
Q. 9. The base address of an array a[3][4] is 502 and size of data type is 2. Find the address of a[1][3] when the array is stored in row major and column major format.
Q. 10. Evaluate the following postfix expression:
42$3*3-84/11+/+
No comments:
Post a Comment