Friday 8 February 2013

Tips to new Fedora users...

Open the TERMINAL and...............



To know the version of Fedora OS...
run the command...
                    cat /etc/issue


TO know whether your OS is 32bit/64bit...
run the command... 
                    uname -i

To install a .rpm file in Fedora...
run the command...
rpm -ivh filename.rpm

tips

1.Did you know when you press F11 when looking at a web page (in MOST cases), the top and bottom extra bars disappear and you see more of the page and less of the browser? Press F11 again to get back to "normal."

2.If you hold down the Control Key and turn the mouse wheel the print on many pages, especially web pages, gets larger and smaller. You get the same effect by holding down control and pressing the plus or minus keys.

3.If you take a desktop computer somewhere, lay it down on its side in the car, with the motherboard side down. The motherboard side is the side with the most plugs and slots close to it. That keeps the RAM and cards from falling out during the jostling drive.

4.Gentle! Easy Does It...!!! ;)
Don't tie those cords, especially LAN cords, like you are wrapping a present! They have tiny wires inside that can easily break. Wrap them loosely. If your internet connection is erratic, it COULD be the cord.


31

Which of the following lines should NOT compile? [explain]

1 int main()
2 {
3 int a = 2;

5 int* b = &a;

7 int const* c = b;
8
9 b = c;
10
11 return 0;
12 }

30

What will be the output ? [explain]
===================
#include <iostream>
int main(int argc, char** argv)
{
int x = 0;
int y = 0;

if (x++ && y++)
{
y += 2;
}

std::cout << x + y << std::endl;

return 0;
}
===================
a. 1
b. 2
c. 3
d. 4
e. undefined

29

Make a function that takes a number as a parameter. Return an integer that is the number divided by two. So for example if the parameter is 10, it will return 5.

*Rules :
=======
No use of any functions.
No use of the '%', '*', and '/' operators.
No use of any classes.

28

#include <stdio.h>
namespace {
int i=10;
printf("%d,",i);
}
int main()
{
printf("%d\n",i);
return 0;
}
--------------------------------
What will be the output ?!
A. 10
B. 10 , 10
C. Compiler error

27

Which of the following sorting algorithms has average-case and worst-case running time of O (n log n) ?
(A) Bubble sort
(B) Insertion sort
(C) Merge sort
(D) Quick sort.

26

In quick sort, the number of partitions into which the file of size n is divided by a selected record is .......
a. n
b n - 1
c 2

25

what is output of the following program ? [with explain]

void main()
{
int i=32767;
printf("%d",++i);
}

24

Which of the following function declaration is/are incorrect?

A. int Sum(int a, int b = 2, int c = 3);
B. int Sum(int a = 5, int b);
C. int Sum(int a = 0, int b, int c = 3);
D. Both B and C are incorrect.
E. All are correct

23

Reference is like a _____.

A. Pointer B. Structure
C. Macro D. Enum

22

What will be output of following program?

#include<stdio.h>
unsigned long int (* avg())[3]{
static unsigned long int arr[3] = {1,2,3};
return &arr;
}
int main()
{
unsigned long int (*ptr)[3];
ptr = avg();
printf("%d" , *(*ptr+2));
return 0;
}

(A) 1
(B) 2
(C) 3
(D) Compilation error
(E) None of above

21

What will be output of following program?

#include<stdio.h>
unsigned long int (* avg())[3]{
static unsigned long int arr[3] = {1,2,3};
return &arr;
}
int main()
{
unsigned long int (*ptr)[3];
ptr = avg();
printf("%d" , *(*ptr+2));
return 0;
}

(A) 1
(B) 2
(C) 3
(D) Compilation error
(E) None of above

20

Write checking leap year program using [C or C++]

Definition of leap year:

Rule 1: A year is called leap year if it is divisible by 400.
For example: 1600, 2000 etc leap year while 1500, 1700 are not leap year.

Rule 2: If year is not divisible by 400 as well as 100 but it is divisible by 4 then that year are also leap year.
For example: 2004, 2008, 1012 are leap year.

19

What will be output of the following program?

#include<stdio.h>
int main(){
int a=0,b=10;
if(a=0){
printf("true");
}
else{
printf("false");
}
return 0;
}

18

What will be output of the following program?

#include<stdio.h>
int main(){
int a=0,b=10;
if(a=0){
printf("true");
}
else{
printf("false");
}
return 0;
}

17

What will be output of the following program?

#include<stdio.h>
int main()
{
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
return 0;
}

16

What will be output ?

#include<stdio.h>
void main()
{
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%o",data[0][2][1]);
}

15

Find the output of calculate(6)

public int calculate(int num)
{
* if(num==0)
** *return 1;
* else
** *return calculate(num-1)*num;
}

14

How many objects and reference variables are created by the following lines of code?

Employee emp1, emp2;
emp1 = new Employee() ;
Employee emp3 = new Employee() ;

13

Complete this program in just one line. It tells the user whether a number is even or odd.

Limitations:
=========
- No use of the Mod(%) operator
- no use of functions
- no use of classes
- no use of / * - +
- a line is counted by the amount of semicolons used. so your return statement counts as one line
- you cannot alter any other line in the code

Code :
======
#include <iostream>
using namespace std;

bool isEven(int f)
{
//one line here
}

int main (int argc, char * argv[])
{
int f = 10;
cout << f << ( isEven(f) ? " is even" : " is odd" ) << endl;
return 0;
}

12

What is the following function doing?(Mathematical Expression)

int foo(int x, int n)
{
int val = 1;
if (n > 0)
{
if (n % 2 == 1)
val *= x;
val *= foo(x * x, n / 2);
}
return val;
}

11

What is the output of the following program?

#include <stdio.h>
void e(int);

int main()
{
int a = 3;
e(a);
return 0;
}

void e(int n)
{
if (n > 0)
{
e(--n);
printf("%d ", n);
e(--n);
}
}

(a) 0 1 2 0
(b) 0 1 2 1
(c) 1 2 0 1
(d) 0 2 1 1

10

What is the output of the following program?

#include<stdio.h>
#define x 4+1
int main()
{
int i;
i = x*x*x;
printf("%d",i);
return 0;
}

(a) 125
(b) 13
(c) 17
(d) None of above

9

What is the following function doing?

int foo(int a, int b)
{
int c = a, d = b;
while(a != b)
{
if(a < b)
a = a+c;
else
b = b+d;
}
return a;
}

8

What is displayed by :

System.out.println("1" + new Integer(2) + 3);

a. The statement has a syntax error and won't compile
b. 6
c. 15
d. 123
e. ClassCastException

7

Consider the following pseudocode:

declare a stack of characters
while ( there are more characters in the word to read )
{
read a character
push the character on the stack
}
while ( the stack is not empty )
{
write the stack's top character to the screen
pop a character off the stack
}

What is written to the screen for the input "carpets"?

A. serc
B. carpets
C. steprac
D. ccaarrppeettss

6

Write a one line code to check if a number is a power of 2.
Example : 8 = 2^3 so 8 is a power of 2 , 9 is not a power of 2.
Hint : you need to know about Bitwise Operators.

What will be output of following c code?

#include<stdio.h>
int main()
{
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}

5

What will be output of following program?

#include<stdio.h>
int main()
{
int a = 320;
char *ptr;
ptr =( char *)&a;
printf("%d ",*ptr);
return 0;
}

(A) 2
(B) 320
(C) 64
(D) Compilation error
(E) None of above.

4

Which of the following statement is correct about the program given below?

#include<iostream.h>
int main()
{
int x = 80;
int y& = x;
x++;
cout << x << " " << --y;
return 0;
}

A. The program will print the output 80 80.
B. The program will print the output 81 80.
C. The program will print the output 81 81.
D. It will result in a compile time error.

3

Which of the following statement is correct about the program given below?

#include<iostream.h>
int BixFunction(int m)
{
m *= m;
return((10)*(m /= m));
}
int main()
{
int c = 9, *d = &c, e;
int &z = e;
e = BixFunction(c-- % 3 ? ++*d :(*d *= *d));
z = z + e / 10;
cout<< c << " " << e;
return 0;
}

A. It will result in a compile time error.
B. The program will print the output 64 9.
C. The program will print the output 64 10.
D. The program will print the output 64 11

2

Which of the following statement is correct?
A. C++ enables to define functions that take constants as an argument.
B. We cannot change the argument of the function that that are declared as constant.
C. Both A and B.
D. We cannot use the constant while defining the function.

1

Which of the following statements is correct?

1 - Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
2 - A reference is not a constant pointer.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Join me on Facebook