Friday, September 16, 2011

Java versus C versus C++


Note:
1)      In java we can return an array of character as the return type of a function.
Eg : char[] display()
   {
      char[] ch = {‘a’, ‘b’, ‘c’};
      ch[1] = ‘A’;
      ch[0] = ‘B’;
      return ch;
   }

Guess???
Can we return an array of character in C and CPP without using pointer?

2)      We cannot have “>>” between integer values.

Guess???
Can we do the same in C and CPP?

3)      In C and CPP, 0 is treated as false and positive numbers as true.

Guess???
Is it the same in Java?

4)      We cannot have an inbuilt output function inside a System.out.println() in Java.

Guess???
Can we have such things in C and CPP?

5)      How can we print “//” using a printf() or cout or println()?



Please drop me a mail to get the answer to kleponymanipur@gmail.com
Further for such differences, notes write to kleponymanipur@hotmail.com
For any further improvement in this blog, please write to klepony_manipur@yahoo.co.in


Wednesday, March 16, 2011

Programming Languages important notes





Points to remember:
1)  1) If an integer is starting with “0” it means it is an octal number. So 010 is not equal to 10.
2)   2)  i = i++;
    i = ++i;

First statement assignment is lost because it is of self- assignment
Second statement assignment is not lost because it is pre-assignment.

3)     int i,j;
   for (i=5,j=3; j<i ; ++j,i--)
       j = j * i;       // i = i * j, it gives garbage value
   for (j=5,i=3; i<j; ++i,j--)
       i = i * j;       // j = j * i, it gives garbage value
   printf("%d\n",i);
   printf("%d\n",j);
4)     4) If the function value are passed as value it retains its original value but if it is passed as reference the values get changed.
5)     5)  && cannot be applied to two int values in java.
6)      6) & only works on java loops.
7)      7) Values need to be initialized for the variable whose calculation needs to be done.
8)      8) int array can be initialized in single quotes. It takes the ASCII value for the respective character which we initialized.
9)      9) Continue can be followed after break, but it won’t have any effect on the remaining code.
10  10)   For loop without body will run until the condition fails.
Thus,  for (i=0;i<5;i++) == for (i=0;i<5;i++)  {     }
1    11)   Any statements after break and continue will give a warning in java.