For BSc (IT) and B.Sc.(Computer Science) students of University of Mumbai

## Sunday, September 28, 2008

### Mad Science - Nine of the oddest experiments ever

### More Computer Notes now available online

King Saud University - Saudi Arabia - They have put up many of my Java notes.

http://groups.msn.com/ComputerNotesOnline/ - You should have a Hotmail or Microsoft Live account to use this.

Notes Online at Yahoo Groups - This requires that you have a Yahoo email account.

My notes at Elphi web site.

Notes for MSc Comp Sc (also useful for BSc and other classes)

## Sunday, September 21, 2008

### What does one do Now?

I am not in a position to engage any lectures till the clouds clear up. When and whether that will happen, only God knows. But my commitment to my students remains. So if you have doubts, pls send an email or leave a comment on this blog. Will do my best to answer your queries.

And yes, do pray for better sense to prevail.

## Wednesday, September 17, 2008

### Careers in Computing

http://computingcareers.acm.org/

### Another New Opportunity for IT Professionals

Before you jump up with "but we are not commerce students", let me tell you this is not only for commerce or finance guys. Have a look at todays (17.9.2008) Ascent of Times Of India (Mumbai). Have a look at this web site for more on Financial Engineering: http://www.iafe.org/resources_what.html

IIM Calcutta offers a course in FE. Another one is the Institutre of Capital Markets (http://utiicm.com/ferm/index.asp#12)

Have a look at this career too!

## Friday, September 12, 2008

### C Assignment # 4

1. Write a C program to compute the roots of a quadratic equation ax^2 + bx + c = 0. Coefficients a, b and c will be input by the user using scanf() function.

2. Explain the following terms with reference to C programming, and give suitable examples:

syntax error, logical error, and run-time error.

3. What is the filename extension of a program in C language?

4. Which software do you use to run C programs? Study this software and prepare a report on the following features of this software:

a. Editing Options

b. Debugging options

c. Compiling and running options

d. Window options

e. Environment options.

5. Write a program in C to convert distance in kms to equivalent distance in mts. E.g. if input is 267 kms, output should by 267000 mts. Be careful with the data types you use!

6. Banks pay an interest on the money you keep with them. Assume that the banks compute interest using the simple interest formula I = PRT/100. Compute the amount of money receivable at the end of T years when a principal sum of P is kept at an interest rate of R.

7. How will you modify the above problem if interest is paid using compound interest formula (interest compounded quarterly)? Look up the formula for compound interest on the Net or derive it on your own.

### C Assignment # 3

1. A C program contains the following declarations:

int i = 8, j = 5;

float x = 0.005, y = -0.01;

char c = 'c', d = 'd';

Determine the value of each of the following expressions. Use the values initially assigned to the variables for each expression.

(a) -(i + j)

(b) ++x

(c) c == 99

(d) y--

(e) --j

(f) j != 6

(g) 2 * x + ( y == 0)

(h) !(c == 99)

(i) (i > 0) && (j <> 0) || (j < i =" j" style="font-style: italic;">getchar() and the putchar() function in C.

3. Write a program in C to read in a line of lower-case text and convert it into upper-case text. Use the getchar() and putchar() functions. Assume that the line is terminated by the newline ('\n') character.

4. What is the purpose of the scanf() function? What is the purpose of the control string in a scanf() function? What is the use of the ampersand symbol in scanf()? If & symbol is not used with a variable in scanf() will it result in a syntax error?

5. What is the purpose of the printf() function? In printf() function, must the variable names be preceded by the ampersand function?

### C Assignments # 2

1. Describe the 5 arithmetic operators in C.

2. Consider an arithmetic expression where the operands are of different types. What are the rules that apply to such expressions?

[Ans: Consider the expression a + b, where a and b are variables.

(i) If a is floating point and b is double, then float variable is converted into double and the result is in the data type double.

(ii) If a is a floating point variable and b is an int data type, then b is converted into float type and then the expression is evaluated.

(iii) If a is int and b is long int, then a is converted into data type long int before the calculation is done.

]

3. What are the unary operators in C?

4. State the relational operators in C. What is the output an expression containing relational operators? Give appropriate examples.

5. State the logical operators in C. Give appropriate examples.

6. With the help of an examples, explain the use of the conditional operator (ternary operator) in C.

7. With appropriate examples, explain the pre-increment and post-increment operators.

8. With appropriate examples, explain the pre-decrement and post-decrement operators.

9. What are pre-processor directives? Give two pre-processor directives that you have used in C programs.

10. What are library functions in C? Give 5 examples and explain in brief.

## Tuesday, September 2, 2008

### BINARY SEARCH ALGORITHM

__BINARY SEARCH ALGORITHM__

The binary search algorithm is used to find out whether an element *'x'* is present in a set of data which is in ascending order.

Consider a numeric array of size '*n´*which is sorted in ascending order. We have to search for an element *'*x´in this array.

Elements of this array can be written as A(1), A(2), A(3), … A(n). First find the middle value in the array, as follows:

If the array contains ** even** number of elements, then:

Middle element = (n + 1) DIV 2

Compare the value of x with this middle element.

If the value of x is greater than the value of the middle element, adjust the lower limit like this:

Middle = (lower + upper) DIV 2

__Algorithm:__

2. Set upper and lower limits.

3. Repeatedly:

a) Calculate the middle position of the array.

b) If value to be found (x), is greater than middle value, then

Adjust lower limit as:

Lower = middle + 1

Else adjust upper limit as:

Upper = middle - 1

Until sought value is found or lower > upper.

----------------------------------------------------------------------------------------------------------------