Showing posts with label Tech. Show all posts
Showing posts with label Tech. Show all posts

Thursday, May 12, 2016

Basic puzzle questions in C :: MUST KNOWN concepts to every programmers

Basic puzzle questions in C :: MUST KNOWN concepts to every programmers
Please try the below puzzles, which are very basic and also very useful in clearing the concept. Find the answer of all the puzzles in last page.

What will be the output of C puzzles below :-
Q 1>
#include<stdio.h>
int main()
{
  char *p=(char *)malloc(sizeof(char)*4); p="abc";
   char q[]="abc123";
     if(p[0]=q[0])
   {
       printf("%c, %c\n",*p,*q);
   }
}

Q 2>
#include<stdio.h>
int main()
{
  char *p=(char *)malloc(sizeof(char)*4); p="abc";
   char q[]="abc123";
     if(q[0]=p[0])
   {
       printf("%c, %c\n",*p,*q);
   }
}


Q 3>
main(){
    int num[] = {1,4,8,12,16};
    int *p,*q;
    int i;
    p =  num;
    q = num+2;
    i = *p++;
    printf("%d, %d, %d\n",i, *p, *q);
}

Q 4>
main(){
char *a[4]={"jaya","mahesh","chandra","swapant"};
int i = sizeof(a)/sizeof(char *);
printf("i = %d\n", i);
}

Q 5>
void fun(int *a, int *b)
{
 int *t;
 t=a;
 a=b;
 b=t;
printf(%d, %d\n",*a, *b);
}
main()
{
     int a=2;
     int b=3;
     fun(&a,&b);
     printf(%d, %d\n",a, b);
}

Q 6>
main(){
    int i =0;
    i = 2+3, 4>3, 3;
    printf("%d", i);
}

Q 7>
main(){
    printf("%u", -1);
}

Q 8>
struct ABC{
    float a:10;
    int b:6;
    char c;
} structure;
int main(){
    int i = sizeof(struct ABC);
    printf("%d", i);
}

Q 9>
#include<stdio.h>
int main() {
    char x[] = "abc";
    char *y = x;
    *y ='1';
    printf("%s",y);
}

Q 10>
main(){
    int i =0;
    i = 4>3, 2+3, 3;
    printf("%d", i);
}

Q 11>
#include<stdio.h>
void fun(int str,...);
int main()
{
    fun(6,"Hello","World","5","6","7","8");
    return 0;
}
void fun(int str,...)
{
    int i;
    int *n=&str;
    for(i=1;i<=str;i++)
    printf("%s ",*(n+i));
    return 0;

}

ANSWERS::
1> Segmentation Fault
   Reason-> We can't assign value to pointer valriable like this.
Different ways to assign value to pointer valriable. 
char *p="Hello World";
char *p=new char[11];  p="Hello World";
Wrong ways which lead to segmentation fault::
p[0]='a'; if(p[0]=='a'){};  *p='a'; if(*p=='a'){};
2> a, a

3> 1, 4, 8

4> 4

5> 3, 2
   2, 3
6> 5
   Explanation:: It stores only the first value.

7> 4294967295   :: As the size of unsigned int is from 0 to 4,294,967,295. -1 will print the back side of zero i.e. 4294967295.

8> Compilation Error:: We cannot use but filed for Float.

9> 1bc

10> 1  ::4>3 return 1 as it is true.

11> Hello World 5 6 7 8


Please comment if you find any thing wrong also please post the questions which you feel need to be shared.

Sunday, January 31, 2016

RoHS

RoHS Explained

RoHS - Restriction of Hazardous Substance

Sometimes we see RoHS in the Printed Circuit Board (PCB) and we just leave then by thinking that there may be some parameter. But today I am going to explain below about this RoHS.

RoHS is short for Directive on the restriction of the use of certain hazardous substances in electric and electronic equipment and it was adopted by European Union in February 2003.

It is an European legislation that bans six hazardous substances from manufacturing processes: cadmium (Cd), mercury (Hg), hexavalent chromium (Cr (VI)), polybrominated biphenyls (PBBs), polybrominated diphenyl ethers (PBDEs) and lead (Pb).
RoHS is also known as "Lead free Directive" but this law deals with other five substances as well.
This legislation is effective July 1st, 2006 and from this date on products using these substances cannot be sold in Europe anymore. Together with RoHS, another directive dealing with the recycling of electrical and electronic equipment, called WEEE (Waste from Electrical and Electronic Equipment), will take place.
Because of RoHS, manufacturers of electronic equipment will have to rush to deliver lead-free equipments in order to be able to sell their products in Europe.

RoHS PCB
The problem is that solder traditionally uses 60% of tin (Sn) and 40% of lead (Pb) and manufacturers will have to research other materials to make solder. As you know, solder is what “glues” all the electronic components on the printed circuit board (PCB) of an electronic product. The most common replacements for lead are silver, copper and bismuth.
These alternative materials, however, bring several challenges:
·         Higher melting temperature: traditional tin/lead solder melts at 180° C (356° F) while lead-free solder melts at 227°C (441°F). This means that the electronic components must be able to support this new soldering temperature in order to allow lead-free solder to be used.
·         Still under development: tin/lead solder is used for ages and the soldering process using this alloy is very well known. Lead-free solder is still a child and a lot of research and development is still going on with several different materials. So far there is no industry standard for lead-free solder.
·         Repair: when repairing electronic equipment, the solder used should also be lead-free. The repair technician should know exactly what kind of solder was used when the equipment was manufactured. Usually this is marked on the printed circuit board (PCB) of the equipment, but this information may not be available. But it is safe to use 99C alloy (99.7% tin, 0.3% copper) when repairing lead-free equipments.
·         Visual inspection: lead-free solder joints look a lot different to traditional tin/lead joints and an untrained eye can assume that the joint is faulty.
Of course besides the solder all other pieces of the electronic equipment – like components and the printed circuit board (PCB) – should have none of the six banned materials to be considered RoHS-compliant and allowed to be sold in Europe.

Why Lead?
The whole problem is basically with the electronic waste. A lot of electronic equipments are ending their lives in open junkyards and waste dumps all around the world – many of them with no chemicals control. The water from acid rain dissolves lead and other hazardous materials from electronic equipment, and the rainwater mixed with these materials go straight to the water table and then to the drinking water.
Lead can affect almost every organ and system in the body, especially the central nervous system. Kidneys and the reproductive system are also affected. The effects are the same, whether it is breathed or swallowed. At high levels, lead may decrease reaction time, cause weakness in fingers, wrists, or ankles, and possibly affect the memory. Lead may also cause anemia.
It is interesting to note that although the electronics industry has been directly targeted for lead removal by the European law, only a small proportion of lead is actually used in electronic equipment production: only 0.49% of all manufactured lead is used in solder and only 2% of the manufactured lead is used in all electro-electronic industry. Battery manufacturing, for example, consumes 80% of the manufactured lead.

And How About the USA?
Even though the United States have no legislation similar to RoHS or WEEE, the state of California passed a law prohibiting the sale of any electronic product that would be prohibited from sale in Europe because of the presence of heavy metals. This law, which is being called “California RoHS”, was effective September 2003, with a compliance deadline of January 2007.

Friday, October 23, 2015

How to use Beetel Adsl2 + Router-450TC1 as switch and Wifi router only

Once I had a problem that I had two ADSL Wifi Routers, one was connected to WAN (Phone line, since I was having Airtel broadband connection) but other one was extra. I wanted to use the extra one as wifi router. But I was not getting how to do this !!

After searching a lot in internet finally I found the solution.

Things required-
1. LAN cable to connect two routers.
2. desktop/Laptop

All below settings are changed in Extra modem. Do not change any setting in the primary modem which is connected to WAN.

1. Reset the extra modem to factory setting.
Steps to reset -
* Press the resent button. You can easily find it in back of the router. 
* Press the resent button and wait for 30 seconds while plugged in and cut the power while continue       to press it for next 10 seconds. 
* Now power on the router.

2. Now use LAN cable to connect router and your Desktop or Laptop. 

3. Now access you router by entering the address 192.168.1.1 in your browser. It will connect you to the router.

4. Now change the default IP address used to access the router. Both router must have different address to access them. Generally it remain 192.168.1.1. You can change it to 192.168.1.2.

5. Now open the 192.168.1.2(it may be different, depends upon what you set in 2nd step above) in your browser. 

6. Under interface section choose bridge mode.

7. Disable to DHCP mode.

8. Change the Wifi name under SSID name and password under Pre Shared key.

9. Restart the modem.

All done..You must be able to access internet over LAN and wifi from secondary modem.
Enjoy..

Saturday, November 9, 2013

Skip to give extension of the file in notepad

Hey guys many time we have the situation like we don't want to give any extension to our file or we don't want others to know about the file in notepad.

Then just follow the simple steps.

Open the notepad, write the content and at the time of saving use double quotes( "*" ).
 where * is the file name and save it without giving any extension.
e.g.- "abc"

Your files will be encrypted and no others can see the extension or the contents, because they don't know the software which will will open it. If you want to view it again then right lick on the file and open with notepad.

Dos Commands to make bootable usb (Flash drive)


      ********
        STEPS
      ********
first make iso image of the file which you want to make bootable through flash
drive, if you have it allready then fine.
Just mount it to any virtual drive by any iso image mounting software. Insert the
pendrive.

1.open command prompt

write these
2.>cd\

3.>diskpart (new dos window will appear--swith to new window)

4.>list disk (Shows the list of disks)

5.select disk 0/1/2/3/.. (In place of 0/1/2/3/.. write the disk sequance which is
of USB pendrive,just see the
size and recognize the pendrive sequance,,, let here a
variable "y")

6.>clean

7.>create partition primary

8.>select partition y

9.>active

10.>format fs=fat32 ( wait till the flash deive is formatted....)

11.>assign

12.>exit ( go to old(main window)

13.>xcopy (source mounted drive letter):\*.* /s/e/f (destination mounted drive
letter(flash drive)):\

it will take time and when it is done ... you done it!!!


www.soft9871.co.cc

Know your PC's complete details using nfo file.

What is a *.nfo file?

It is a file which on execution shows sysyem info which is directly and automatically liked with "msinfo32.exe" file the system. the msinfo.exe file rmains in sysem32 directory.

You can write any thing inside the nfo file, any thing but save it by giving the extention nfo file.

Whenever you see a *.nfo file and if you double click on it will shows the system information but if you want to see the text message you have to open it by notepad. never change default opening of the file. If you set to always open as notepad then you will never be able to see the system details by just double clicking over the nfo file.

By the way if you have set to always open with notepad and want to see the system details then open the run window and type "msinfo32.exe' and press enter. you will see a new window opening and showing different properties of the system

How to mount Linux on flash drive


DOS Commands to make bootable usb(Flah drive)
      ********
        STEPS
      ********
first make iso image of the file which you want to make bootable through flash
drive, if you have it allready then fine.
Just mount it to any virtual drive by any iso image mounting software. Insert the
pendrive.

1.open command prompt

write these
2.>cd\

3.>diskpart (new dos window will appear--swith to new window)

4.>list disk (Shows the list of disks)

5.select disk 0/1/2/3/.. (In place of 0/1/2/3/.. write the disk sequance which is
of USB pendrive,just see the
size and recognize the pendrive sequance,,, let here a
variable "y")

6.>clean

7.>create partition primary

8.>select partition y

9.>active

10.>format fs=fat32 ( wait till the flash deive is formatted....)

11.>assign

12.>exit ( go to old(main window)

13.>xcopy (source mounted drive letter):\*.* /s/e/f (destination mounted drive
letter(flash drive)):\

it will take time and when it is done ... you done it!!!


www.soft9871.co.cc

Create a file with blank name in Windows


Q: How to create a blank folder or File name?

A: To create a file with blank name(i.e. the name will be nothing).
To do this right click over the file and click on rename option.
Now press the following keys without pressing any key...
"Alt+0160" or "Alt+255"
and then press enter.

Note:- To enter the numeric value use numkeypad i.e. the number keys in the right side of the keyboard. If you are using laptop then first activate the number keys.



Q: How to hide a file?

Two options--
1. In advanced setting of the file check the hide option there.
2. First rename the file by a blank(null) file name by above ways, and then change the icon of the file by any of transparent file provided by windows in default icons.


Right Click the New Folder, go to Properties, then to Customize, and then click Change Icon. Here is the trick, go to the middle and you should see some blank spaces. Those are transparent icons, select one of those then press OK -> Apply -> OK.

Saturday, October 26, 2013

Windows XP Bliss Wallpaper

Windows XP bliss wallpaper
Have you ever thought about the very popular wallpaper of windows?

Where the image has been taken and who taken this?




It is an actual picture, taken from camera.
Location:- Sonoma County, California, southeast of Sonoma Valley near the site of the oldClover Stornetta Inc. Dairy.
The image contains:- rolling green hills and a blue sky with stratocumulus and cirrus clouds.
Picture Taken by:- Charles O'Rear from Napa(County). Charles was a professional photographer.
Most important thing is that photo was not digitally enhanced
Photo taken on:- 1996 (5 years before the release of windows XP.)
Coordinates of the place:- 38.250124,-122.410817Same place after 10 years in November 2006…. How it looks….


You can see the place in Google earth by just entering the coordinated of the place. Then go to street view.





Sunday, September 25, 2011

How to create Auto run file(Codes)

File type auto run
Extension- *.inf



Classic description--  Autorun file is a very small file in text wgich having extension inf  and contains few codes. It is basically in CD's, DVD's Usb drives etc.. to run a predefined file automatically when it first detected by the windows.

The extension of autorun file is *.inf.


Some coding to make a autorun file.

[AutoRun]
open=Autorun.exe
icon=P18D.ico

Setting a Custom Icon********
icon=coffeecup.ico
icon=DCoTopen.exe
icon=iconlib.dll,2


Naming Your USB Drive*******
label=DCoT Drive


Setting AutoPlay Options********
open=setup.exe  //It will open the setup.exe file.
action=Start the execution       //This command is used to give message along with name.

Adding Context Menu Items*********
shell\lost=Help! I'm Lost!
shell\lost\command=Lost.exe

Viewing a File**********
shellexecute=http://www.google.com