Translate

Labels

Friday 18 January 2013

CHANGING BACKGROUND FOR FACEBOOK

GOOGLE CHROME

FACEBOOK BACKGROUND CHANGER
 chrome.google.com/webstore/detail/facebook-background-                        chang/emnlfbokmiehpnhgdjlmedakkchfldmj

  • go to this address.
  • In right of that page there will be a ADD TO CHROME button click that button then FACEBOOK 
  • BACKGROUND changer will be added to your chrome
  • Then,you can change the BACKGROUND.

Also you can change color by  using FACEBOOK  COLOR changer.
chrome.google.com/webstore/detail/facebook-color-chang/emnlfbokmiehpnhgdjlmedakkchfldmj
  • go to this address.
  • In right of that page there will be a ADD TO CHROME button click that button then FACEBOOK 
  • COLOR changer will be added to your chrome
  • Then,you can change the COLOR.

TRICKS

FACEBOOK COLOR CODES

  • Make colorful chat with your friends.
  • paste the following codes in your chat area and press enter.

[[107015582669715]] = A
[[116067591741123]] = B
[[115602405121532]] = C
[[112542438763744]] = D
[[115430438474268]] = E
[[109225112442557]] = F
[[111532845537326]] = G
[[111356865552629]] = H
[[109294689102123]] = I
[[126362660720793]] = J
[[116651741681944]] = K
[[115807951764667]] = L
[[106596672714242]] = M
[[108634132504932]] = N
[[116564658357124]] = O
[[111669128857397]] = P
[[107061805996548]] = Q
[[106699962703083]] = R
[[115927268419031]] = S
[[112669162092780]] = T
[[108983579135532]] = U
[[107023745999320]] = V
[[106678406038354]] = W
[[116740548336581]] = X
[[112416755444217]] = Y
[[165724910215]]       = Z

Eg:
        for hai = [[111356865552629]]  [[107015582669715]] [[109294689102123]]

Tuesday 15 January 2013

SHELL PROGRAM

ARMSTRONG NUMBER 

echo"Enter the number"
read n
t=$n
s=0
b=0
c=10
while[$n -st $b]
do 
r='expr $n%$c'
i='expr $r \*$r\*$r'
s='expr $s + $i'
n='expr $n / $c'
done
echo a$s
if[ $s -eq $t]
then 
echo"Armstrong number"
else "Not an Armstrong number"
fi


THE GIVEN NUMBER IS PRIME OR NOT

echo"Enter a number:"
read n
flag=0
for((i=2;i<=n/2;i++))
do
r='expr $n %$i'
if[ $r = 0]
then
flag=1
break
fi
done
if [ $flag = 0]
then
 echo"$n is a prime number"
else
echo"$n is not a prime number"
fi

SHELL PROGRAM

QUADRATIC EQUATION

echo"Enter a value:"
read a
echo "Enter a value:"
read b
echo "Enter a value:"
read c
x1=echo "scale=7;(-$b+sqrt($b^2-4*$a*$c))/(2*$a)"|bc'
x2=echo "scale=7;(-$b-sqrt($b^2-4*$a*$c))/(2*$a)"|bc'
echo $x1
echo $x2


SUM OF CUBE OF INDIVIDUAL DIGITS OF A NUMBER

echo"Enter a number:"
read n
t=$n
s=0
while[ $n -gt 0 ]
do 
r='expr $n % 10'
s='expr $s +$r\*$r\*$r'
n='expr $n / 10'
done
echo"The sum of cube of individual digits of $t is $s"

SHELL PROGRAM

FIBONACCI SERIES OF A NUMBER

echo"Enter how many numbers: "
read num
num1=0
num2=1
echo"Fibonacci series:"
echo $num1
echo $num2
count=2
while[ $count-le $num ] 
do 
num3='expr $num1 + $num2'
echo $num3
num1=$num2
num2=$num2
count='expr 4count + 1'
done


DISPLAY TEN LEAP YEARS

for((i=2000;i<=2036;i++))
do
if['expr $i%400'=0]
then
echo"$i is a leap year "
elif['expr $i % 4'=0 -a 'expr $i % 100'!=0]
then
echo"$i is a leap year"
fi
done 

SHELL PROGRAMS

THE SUM OF 'n' DIFFERENT NUMBERS

echo"Enter the number of elements:"
read n
s=0
for((i=1;i<=n;i++))
do 
echo"Enter the number: "
read no 
s='expr $s+$no'
done
echo"This sum is :$s"

REVERSE OF A GIVEN NUMBER 

if  [ $# -eq 1 ]
then 
if [ $1 -gt 0 ]
then 
num=$1
sumi=0
while [ $num -ne 0 ]
do 
lnum='expr $num % 10'
sumi='expr $num * 10  + $lnum '
num='expr $num / 10'
done
echo"Reverse of digits is $sumi of $1 "else
echo"Number is less than  0"
fi
else
echo"Insert only one parameter "
fi

SHELL PROGRAMS

LARGEST AMONG 'n' NUMBERS

echo"Enter the number of elements:"
read n
l=0
for((i=1;i<=n;i++))
do 
echo"Enter the number:"
read no
if[$no -gt$l]
then l=$no
fi
done
echo"The largest number is:$l"

THE LARGEST DIGIT OF A NUMBER

echo"Enter a number:"
read n
s=0
while [ $n -gt 0 ]
do 
r='expr $n%10'
if[$r -gt $s]
then 
s=$r
fi
n='expr $n/10'
done 
echo"The largest digit is:$s"

UNIX COMMANDS


  • pwd:'print working directory' displays the name of the current directory.
  • cd:'change directory' command will change the current directory to the directory specified as the argument to the command.
  • ls:'list files' command displays the files in a directory .
  • ls-l:'long list option' for listing files displays permissions, links, owner, group, file size, modification date,file name.
  • rm:'remove' command deletes ordinary files in a directory.
  • mv:'move' commands moves a file from one location to another.It is also used to rename files,as in 'mv thisfile.txt thatfile.txt'
  • cp:'copy' command creates a copy of a file.
  • chmod: change mode command is used to control access rights to a file or files.
  • mkdir: 'make directory' command creates a directory or sub directory within the current directory .
  • rmdir: 'remove directory' command  removes a directory or sub directory. The specified directory must be empty before it can be removed.
  • find:'find' command is used to locate files.
  • file: 'file' command is used to determine the type of information in the file listed as the argument to the command, i.e..,text or binary.
  • cat:'cat' command displays the content of files,.It is also used to concatenate files as in "cat file1.txt file2.txt file3.txt>allfiles.txt".
  • wc: 'wc' command displays a count of characters, words, and lines in a text file.
  • sort:'sort' command is used to sort and/or merge text files.
  • grep:'grep' commands searches for text strings in files.
  • who:tells who's logged on.
  • finger username:gives you lots of information about that user.
  • diff filename1 filename2: compares  files, and shows where they differ.
  • cp filename1 filename2: copies a file.
  • mv filename1 filename2: moves a file.
  • date: shows the current date and time.
  • cal: shows a calender of the current month.use eg..,'cal 10 2012, to get that for October 12, or 'cal 2012' to get the whole year.
  • tail:used to display the last few lines of a file.
  • head-lines file name:to display the first few lines of a file.
  • cat file1 >>file2: append more than one file.

Monday 14 January 2013

STORAGE CLASS

Storage class is another attribute that is associated with the variable.C provides four storage classes:

  •                    auto,
  •                    static,
  •                    register,
  •                    extern.

A variable's storage class is used to determine its scope and  lifetime auto variables are actually local variables.They are created when the function in which they are declared is entered, and they are destroyed when the function is exited.The variable declared within a function are local to that function.Their scope and lifetime are limited within that function,which means, all the local variables are destroyed when the function execution is over.We cannot access the values of the local variable outside the function.., i.e..,the scope of the local variables is within the function in which they have been declared.consider the following program:
#include<stdio.h>
main()
{
add();
add();
}
add()
{
int i=0;
i=i+1;
printf("%d\n",i);
}
The output of the above program will be 
1
1
      The variable i is a local variable in the add function.Each time the add function is called, the variable i gets recreated and initialized to 0 and hence the result will be always 1.If the variable has been declared as a static variable, its value will be retained even after the function execution is over.change the add function as follows:
add()
{
static int i=0;
i=i+1;
printf("d\n",i);
}
       The variable i has been declared as a static variable.It is local to the add function.Its scope is still within the add function and its value cannot be accessed by any another function.The static variables are created only once during the first call of the function.The main advantage of static variable is that their values are retained even after execution of the function.So,each time, the function add is called, the value of the variable i gets incremented and output will be 
1
2
      The above program is rewritten by declaring i as a global variable.Global variable are declared before the main function.They can be accessed and modified by all the functions in the program.
#include<stdio.h>
int i=0;
main()
{
add();
add();
}
add()
{
i=i+1;
printf("%d\n",i);
}
The output of the above program will be:
1
2
      In the above program, i is a global variable and it can be accessed modified in all functions.The static variables retain the characteristics of local variables.The life time of the static variable as well as the global variable ends only when the entire program execution is over.The scope of the static variable is to the function in which it has been declared.The scope of the global variable is to all the functions in the program.Except these differences, the global variables declared outside any function are static by default.But static variable is not a global variable.
       The register variable behave like auto variables if a variable is declared with register storage class,its value is placed in one of the computer's high-speed hardware registers.If the compiler does not find sufficient variable are used to speed up operations, by reducing memory access time. 
     Global  variable are accessed in the function of a program stored in one file. If the global variable have to be accessed by the function in a file other than the one in which they are declared, the extern storage class can be used.For example, if we define global integer variable count in one file, and refer to it in a second file the second file must contain the declaration extern int count; prior to the variable's use in that file.The extern variables have global scope and the lifetime is throughout the execution of the program

Tuesday 8 January 2013

C PUZZLE


41)     main()
{
                        void swap();
            int x=10,y=8;    
                        swap(&x,&y);
            printf("x=%d y=%d",x,y);
}
void swap(int *a, int *b)
{
   *a ^= *b,  *b ^= *a, *a ^= *b;
}         
Answer:
x=10 y=8
Explanation:
Using ^ like this is a way to swap two variables without using a temporary variable and that too in a single statement.
Inside main(), void swap(); means that swap is a function that may take any number of arguments (not no arguments) and returns nothing. So this doesn’t issue a compiler error by the call swap(&x,&y); that has two arguments.
This convention is historically due to pre-ANSI style (referred to as Kernighan and Ritchie style) style of function declaration. In that style, the swap function will be defined as follows,
void swap()
int *a, int *b
{
   *a ^= *b,  *b ^= *a, *a ^= *b;
}
where the arguments follow the (). So naturally the declaration for swap will look like, void swap() which means the swap can take any number of arguments.

42)     main()
{
                        int i = 257;
            int *iPtr = &i;
                        printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
}
Answer:
                        1 1
Explanation:
The integer value 257 is stored in the memory as, 00000001 00000001, so the individual bytes are taken by casting it to char * and get printed.

43)     main()
{
                        int i = 258;
            int *iPtr = &i;
                        printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
}         
Answer:
                        2 1
Explanation:
The integer value 257 can be represented in binary as, 00000001 00000001. Remember that the INTEL machines are ‘small-endian’ machines. Small-endian means that the lower order bytes are stored in the higher memory addresses and the higher order bytes are stored in lower addresses. The integer value 258 is stored in memory as: 00000001 00000010.  

44)     main()
{
                        int i=300;
            char *ptr = &i;
                        *++ptr=2;
            printf("%d",i);
}
Answer:
556
Explanation:
The integer value 300  in binary notation is: 00000001 00101100. It is  stored in memory (small-endian) as: 00101100 00000001. Result of the expression *++ptr = 2 makes the memory representation as: 00101100 00000010. So the integer corresponding to it  is  00000010 00101100 => 556.
45) void main()
         {
if(~0 == (unsigned int)-1)
printf(“You can answer this if you know how values are represented in memory”);
         }
 Answer
You can answer this if you know how values are represented in memory
Explanation
~ (tilde operator or bit-wise negation operator) operates on 0 to produce all ones to fill the space for an integer. –1 is represented in unsigned value as all 1’s and so both are equal.

46) int swap(int *a,int *b)
{
 *a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
                        int x=10,y=20;
            swap(&x,&y);
                        printf("x= %d y = %d\n",x,y);
}
Answer
            x = 20 y = 10
Explanation
This is one way of swapping two values. Simple checking will help understand this.

47)     main()
{         
char *p = “ayqm”;
printf(“%c”,++*(p++));
}
Answer:
b         

48)     main()
            {
             int i=5;
             printf("%d",++i++);
}
Answer:
                        Compiler error: Lvalue required in function main
Explanation:
                        ++i yields an rvalue.  For postfix ++ to operate an lvalue is required.

49)     main()
{
char *p = “ayqm”;
char c;
c = ++*p++;
printf(“%c”,c);
}
Answer:
b
Explanation:
There is no difference between the expression ++*(p++) and ++*p++. Parenthesis just works as a visual clue for the reader to see which expression is first evaluated.

50)
int aaa() {printf(“Hi”);}
int bbb(){printf(“hello”);}
iny ccc(){printf(“bye”);}

main()
{
int ( * ptr[3]) ();
ptr[0] = aaa;
ptr[1] = bbb;
ptr[2] =ccc;
ptr[2]();
}
Answer:
 bye
Explanation:
int (* ptr[3])() says that ptr is an array of pointers to functions that takes no arguments and returns the type int. By the assignment ptr[0] = aaa; it means that the first function pointer in the array is initialized with the address of the function aaa. Similarly, the other two array elements also get initialized with the addresses of the functions bbb and ccc. Since ptr[2] contains the address of the function ccc, the call to the function ptr[2]() is same as calling ccc(). So it results in printing  "bye".

C PUZZLE


30)     1. const char *a;
2. char* const a;
3. char const *a;
-Differentiate the above declarations.

Answer:
1. 'const' applies to char * rather than 'a' ( pointer to a constant char )
            *a='F'       : illegal
                                    a="Hi"       : legal

2. 'const' applies to 'a'  rather than to the value of a (constant pointer to char )
            *a='F'       : legal
            a="Hi"       : illegal

3. Same as 1.

31)     main()
{
                        int i=5,j=10;
            i=i&=j&&10;
                        printf("%d %d",i,j);
}

Answer:
1 10
Explanation:
The expression can be written as i=(i&=(j&&10)); The inner expression (j&&10) evaluates to 1 because j==10. i is 5. i = 5&1 is 1. Hence the result.

32)     main()
{
                        int i=4,j=7;
            j = j || i++ && printf("YOU CAN");
                        printf("%d %d", i, j);
}

Answer:
4 1
Explanation:
The boolean expression needs to be evaluated only till the truth value of the expression is not known. j is not equal to zero itself means that the expression’s truth value is 1. Because it is followed by || and true || (anything) => true where (anything) will not be evaluated. So the remaining expression is not evaluated and so the value of i remains the same.
Similarly when && operator is involved in an expression, when any of the operands become false, the whole expression’s truth value becomes false and hence the remaining expression will not be evaluated.    
            false && (anything) => false where (anything) will not be evaluated.

33)     main()
{
                        register int a=2;
            printf("Address of a = %d",&a);
                        printf("Value of a   = %d",a);
}
Answer:
Compier Error: '&' on register variable
Rule to Remember:
                         & (address of ) operator cannot be applied on register variables.
           
34)     main()
{
                        float i=1.5;
            switch(i)
                        {
                        case 1: printf("1");
                                    case 2: printf("2");
                                    default : printf("0");
            }
}
Answer:
Compiler Error: switch expression not integral
Explanation:
                        Switch statements can be applied only to integral types.

35)     main()
{         
                        extern i;
            printf("%d\n",i);
                        {
                                    int i=20;
                        printf("%d\n",i);
                        }
}
Answer:
Linker Error : Unresolved external symbol i
Explanation:
The identifier i is available in the inner block and so using extern has no use in resolving it.

36)     main()
{
                        int a=2,*f1,*f2;
            f1=f2=&a;
                        *f2+=*f2+=a+=2.5;
            printf("\n%d %d %d",a,*f1,*f2);
}
Answer:
16 16 16
Explanation:
f1 and f2 both refer to the same memory location a. So changes through f1 and f2 ultimately affects only the value of a.
           
37)     main()
{
                        char *p="GOOD";
            char a[ ]="GOOD";
printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p));
            printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a));
}
Answer:
                        sizeof(p) = 2, sizeof(*p) = 1, strlen(p) = 4
            sizeof(a) = 5, strlen(a) = 4
Explanation:
                        sizeof(p) => sizeof(char*) => 2
            sizeof(*p) => sizeof(char) => 1
                        Similarly,
            sizeof(a) => size of the character array => 5
When sizeof operator is applied to an array it returns the sizeof the array and it is not the same as the sizeof the pointer variable. Here the sizeof(a) where a is the character array and the size of the array is 5 because the space necessary for the terminating NULL character should also be taken into account.

38)     #define DIM( array, type) sizeof(array)/sizeof(type)
main()
{
int arr[10];
printf(“The dimension of the array is %d”, DIM(arr, int));   
}
Answer:
10  
Explanation:
The size  of integer array of 10 elements is 10 * sizeof(int). The macro expands to sizeof(arr)/sizeof(int) => 10 * sizeof(int) / sizeof(int) => 10.

39)     int DIM(int array[])
{
return sizeof(array)/sizeof(int );
}
main()
{
int arr[10];
printf(“The dimension of the array is %d”, DIM(arr));   
}
Answer:
1  
Explanation:
Arrays cannot be passed to functions as arguments and only the pointers can be passed. So the argument is equivalent to int * array (this is one of the very few places where [] and * usage are equivalent). The return statement becomes, sizeof(int *)/ sizeof(int) that happens to be equal in this case.

40)     main()
{
            static int a[3][3]={1,2,3,4,5,6,7,8,9};
            int i,j;
            static *p[]={a,a+1,a+2};
                        for(i=0;i<3;i++)
            {
                                    for(j=0;j<3;j++)
                                    printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j),
                                    *(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i));
                        }
}
Answer:
                                    1       1       1       1
                                    2       4       2       4
                        3       7       3       7
                                    4       2       4       2
                                    5       5       5       5
                        6       8       6       8
                                    7       3       7       3
                                    8       6       8       6
                        9       9       9       9
Explanation:
                        *(*(p+i)+j) is equivalent to p[i][j].