Showing posts with label ashiztooambitious. Show all posts
Showing posts with label ashiztooambitious. Show all posts

Thursday, September 15, 2011

Decimal to Binary, Decimal to Octal, Decimal to Hexadecimal


Convert Decimal to Binary, Decimal to Octal, Decimal to Hexadecimal using C Programming.

void main()


{
int bin[20],oct[20];
char hex[20];
int i=0,j=0,h=0,k,m,l,dec,dec1,dec2,r;
clrscr();


printf("\n\n\t\tSay thanks to Ashish Ranjan !!!");

printf("\n\n\t\tEnter your Number : ");
scanf("%d",&dec);
printf("\n\t\tDecimal Number : %d\n\n ",dec);


dec1=dec2=dec;
//----------------------Binary--------------------------------------


while( dec != 0)
{
   k=dec/2;
   bin[i]=dec%2;
   dec=k;
   i++;
 //  printf("\n quo = %d,\trem = %d,\tdividend = %d,\ti = %d",k,bin[i-1],dec,i);
}


printf("\n\n\n\t\tBinary Represnetation :  ");
for(i=i;i!=0;i--)
    {printf(" %d",bin[i-1]);}




//----------------------Octal---------------------------------------
 printf("\n\n\n");
while( dec1 != 0)
{
   m=dec1/8;
   oct[j]=dec1%8;
   dec1=m;
   j++;
//  printf("\n quo = %d,\trem = %d,\tdividend = %d,\tj = %d",m,oct[j-1],dec1,j);
}


printf("\n\n\t\tOctal Represnetation :  ");
for(j=j;j!=0;j--)
    {printf(" %d",oct[j-1]);}
//------------------------HexaDecimal-------------------------------


 printf("\n\n\n");
while( dec2 != 0)
{
   l=dec2/16;
   r=dec2%16;
    if(r<10)
   { hex[h]=r; }
   else if(r==10)
   { hex[h]='A';}
   else if(r==11)
   { hex[h]='B';}
   else if(r==12)
   { hex[h]='C'; }
   else if(r==13)
   { hex[h]='D'; }
   else if(r==14)
   { hex[h]='E'; }
   else if(r==15)
   { hex[h]='F'; }


   dec2=l;
   h++;
//  printf("\n quo = %d,\trem = %d,\tdividend = %d,\th = %d\thd = %d",l,r,dec2,h,hex[h-1]);
}


printf("\n\n\t\tHexadecimal Represnetation :  ");
for(h=h;h!=0;h--)
    { if(hex[h-1]>10)
      printf(" %c",hex[h-1]);
      else
      printf(" %d",hex[h-1]);
    }
 getch();
}








Triangle Pattern using for loops

How do you create a Triangle Pattern using for loops?



 


#include<stdio.h>

#include<conio.h>

void main ()

{
int pas,i,j,k;
clrscr();
printf("\n\n\tEnter the size of pascal triangle (upto 99) : ");
scanf("%d",&pas);
printf("\n\n\n");

for(i=1;i<=pas;i++)
   {
    for(j=pas;j>i;j--)
       {
printf(" ");  }
    for(k=1;k<=i;k++)
       {
printf("%2d",i);  
// printf(" *",i);    /* to print the pattern with asterisk
                            uncomment it and comment the above 
                            statement */
       }
    printf("\n");

   }
printf("\n\n\n\t  Pascal Triangle %d",pas);
getch ();
}



Tuesday, January 25, 2011

Disable or Enable USB port or device

Steps to disable or enable USB port or device

USB Devices are portable enough to carry the data from one computer to another , It is always risky to enable USB ports of computers in large organizations , data center and cyber cafes since it can be the gateway for virus and malwares. You can disable or enable USB port or device in two ways :-

Enable / Disable USB port and device in BIOS
It can be enabled or disabled in BIOS where the peripheral device setting is configured. While booting the system you will be getting an option to configure BIOS settings. But only problem is you will not be able to use those USB ports for any purpose like connecting USB keyboards or mouse or any devices.

Enable / Disable USB port and device using registry hack in windows
Another effective way to enable or disable USB port or device is to hack registry entry in windows , it will allow you to use your USB port for other functions like connecting keyboard or mouse but you can restrict the data storage through USB port

A. Click on Start –> Run –> regedit [enter]
B. Search for the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
C. Select the key UsbStor, double clicks on Start value.
D. In “Value data” enter 4 to disable USB storage, or enter 3 to enable USB storage on windows system