Translate

Labels

Monday 29 April 2013

SHOWING DATE AND TIME OF YOUR LOCAL PC TIME USING C PROGRAM

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textcolor(6);
cprintf("Showing date and time \n");
printf("\n");
textcolor(2);
cprintf("Date:%s",DATE);
printf("\n");
textcolor(4);
cprintf("Time:%s",TIME);
getch();
}

cprintf() function you can see color formatted output.
textcolor() function gives the specific color.
By executing this program you can see the current date and time of your local PC time.

Saturday 27 April 2013

ALL PERFECT SQUARE BELOW 1000

/*PROGRAM TO PRINT ALL PERFECT SQUARES BELOW 1000*/
#include<stdio.h>
main()
{
int i=1;
printf("The perfect squares below 1000 are\n");
while(i*i<1000)
{
printf("%5d",i*i);
i++;
}
getch();
}

SUM THE FIRST 50 EVEN NATURAL NUMBERS

/*PROGRAM TO SUM THE FIRST 50 EVEN NATURAL NUMBERS*/
#include<stdio.h>
main()
{
int sum=0,i=2;
while(i<=100)
{
sum+i;
i+=2;
}
printf("Sum of first 50 even natural numbers=%d\n",sum);
getch();
}

OUTPUT
Sum of first 50 natural numbers=2550


Sunday 14 April 2013

DENSITY OF TAPE

Density of a tape is referred to as the number of frames per inch(fpi) or character per inch(cpi) rather than bits/bytes per inch(bpi) Regardless of which term is used,a frame or byte is a group of related bits that make up a single character written across the width of the tape.

IBM

In 1896,Hollerith founded the Tabulating Machine company,which was later named IBM (International Business Machines)IBM developed numerous mainframes and operating systems,many of which are still in use today.For example IBM co-developed  OS/2 with Microsoft, which laid the foundation for windows operating system.

Saturday 6 April 2013

USB SYSTEM LOCK

BOOT LOCK

This lock will allow you to use your USB stick as a key to boot into windows.If someone tries to start the computer without your USB stick, it will display boot errors. Before we begin let us tell you that playing with the BIOS and files of your computer may result in you not being able to boot into your partition;so continue at your own risk!
Now that we have absolved ourselves of all guilty,let's begin.
Things you need:A 64MB or larger sized USB stick,windows recovery disk.(Just in case)
Steps:
1) Unhide hidden and protected files: goto Tools>options>view, check show hidden files and unchecked hide protected system files.

2)From the driver where Windows is installed(normally C:\), copy the files boot.ini,ntdlr and NTDETECT.COM to your USB Stick.

3)Now,we need to go into your BIOS,so restart the computer and keep jabbing[F8] as soon as the computer starts.

4)Once in the BIOS,enable USB Drive as the first boot device.You might have to enable USB Legacy support on older BIOSes.

5)Restart your computer if all goes well you should be able to lg into windows.If not,then unplug the USB stick,return to the BIOS and change the first Boot device to your hard disk and repeat the steps above.

6)Once your are logged into Windows drive and rename boot.ini to boot.bak.

7)To check if you have setup everything correctly,eject your USB stick and reboot the computer.You should get error messages on the screen such as "Invalid Boot.ini" or "Windows could not start".

8)In case Windows does not load,use yours windows recovery disk by following the steps mentioned at http://tinyurl.com/s9sd2.

The other way

For the less brave-hearted,  instead of preventing Windows from booting you can choose to just lock your computer with your USB stick.

USB system Lock

A freeware program,USB system lock Works flawlessly while locking and unlocking your computer.When you install USB System Lock, it detects your USB stick  and creates a digital key on it.This key is used by the program to authenticate the user and log into the computer.
Strangely,the program is not included in the start-up list by default.
to add it there,you need it to drag agent from the USB system lock entry under all programs to the start up folder in the same menu.If you happen to accidentally delete the key from your USB stick while working on the protected computer you can reassign a key using start>programs>USB system lock>Key Disk Generator.

My Lock 2.0

This program takes USB-based computer locking to whole new level.You can look access to not only your PC but the keyboard,CD Drive and even access to safe mode.You can also set a particular time for the computer to automatically lock itself.What is most interesting about the phrase so that you can use it log into the computer even without the stick plugged in

Friday 5 April 2013

PROCESSING ONE DIMENSIONAL ARRAY

TO SEARCH FOR A NUMBER IN A LIST OF NUMBERS

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10},n,i,f,s;
clrscr();
printf("Enter the no of numbers \n");
scanf("%d",&n);
printf("Enter %d numbers \n",n);
for(i=0;i<n;i++)
scanf("%d",a[i]);
printf("Enter the number to be searched \n");
scanf("%d",&s);
/* searching for s in a begins */ 
f=0;
for(i=0;i<n;i++)
if(a[i]==s)
{
f=1;
break;
}
/*searching for s in a ends*/
printf("\n List of elements \n");
for(i=0;i<n;i++)
printf("%d",a[i]);
printf("\n Enter to be searched \n");
printf("\n s=%d \n",s);
if(f==1)
printf("%d is found",s);
else
printf("%d is not found",s);
getch();
}
OUTPUT
Enter the no of numbers
5
Enter 5 numbers
1   2   3   4   5
Enter the number to be searched 
3
List of elements 
1   2   3   4   5
Elements to be searched
3
3 is found
Explanation
a is declared to be array of int type of size 10.Maximum 10 values can be read into the array.n,i,s and f are declared to be variable of int type.n is to collect the number of values to  be read into a, which lies within 1 and 10.i is to traverse all the elements of a.s is to collect a value which is to be searched.f is to be determine whether s is found in a or not.It acts as a flag variable.The procedure of searching for s in a is implemented in the following segment of the program.
f=0;
for(i=0;i<n;i++)
if(a[i]==s)
{
f=1;
break;
}
before searching begins,f is set to zero with the assumption that s is not available in a.During the course of searching that is inside the body of the for loop, if s is found t match with any element in the array, f is set to 1  and loop is excited. If s takes 1 then it means s  is found in a.If f retains 0,we conclude that s s not fond in a.The value of f would thus tell us whether s is found in a or not.  

Thursday 4 April 2013

PROCESSING ONE DIMENSIONAL ARRAY

TO ACCEPT A LIST OF NUMBERS INTO A 1-d ARRAY, FIND THEIR SUM, AVERAGE AND DISPLAY THEM.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n, sum;
float avg;
clrscr();
printf("Enter no.of elements [1-10]\n");
scanf("%d",&n);
printf("Enter %d numbers \n ",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("The number are \n");
for(i=0;i<n;i++)
printf("%4d",a[i]);
/*Finding the sum and average begins*/
sum=0;
for(i=0;i<n;i++)
sum+=a[i];
avg=(float)sum/n;
/*Finding the sum and average ends*/
printf("\n Sum=%d\n",sum);
printf("\n Average=%f\n",avg);
getch();
}
OUTPUT
Enter no.of elements[1-10]
5
Enter 5 numbers
1   2   3   4   5
The numbers are
1   2   3   4   5
Sum=15
Average=3.000000
Explanation
a is declared to be an array of int type and of size 10.Maximum 10 numbers can be written into the array.n,i and sum are declared to be variable of int type.n is to collect the number of values to be read into the array a,which lies within 1 and 10.i is to traverse all values in a sum is to collect the sum of the values in a avg is declared to be a variable of float type and it is to collect the average of values in a.
In the process of finding the sum of all the values initially sum is set to 0.A for loop is used select each number in the array and it added to sum with the statement.
sum+=a[i]
The statement
avg=(float)sum/n;
on its execution assign average value to avg. Note that we have used type casting to convert sum forcibly to float to get the exact result.Otherwise the expression (sum/n) produces only integral part of the quotient since both sum and n are integers.Both sum and avg are then displayed 

Wednesday 3 April 2013

PROCESSING ONE DIMENSIONAL ARRAYS

TO ILLUSTRATE DECLARATION, INITIALIZATION OF A ONE-DIMENSIONAL ARRAY AND DISPLAYS ITS ELEMENTS.

#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[5]={2,3,5,6,7};
clrscr();
printf("The elements of array a \n");
for(i=0;i<=4;i++)
printf("%3d",a[i]);
getch();
}
OUTPUT:
The element of array a
2   3   5   6   7
Explanation
a is declared to be an array of int type and of size five and also is initialized while it is declared.i is a variable of int type and it is used to traverse the elements of a.
To display the elements of a,we have used for loop to repeatedly call printf().The loop variable i is made to range from 0 to 4.When i takes 0, the first element is displayed.When i takes 1,the second element is displayed and so on.  

Tuesday 2 April 2013

X TO THE POWER Y

#include<stdio.h>
#include<conio.h>
float power(int x,int y)
{
float p;
if(y==0)
return(1);
else if(y>0)
p=x*power(x,y-1);
else
{
p=1/power(x,-y);
}
return(p);
}
void main()
{
int x,y;
float p;
clrscr();
printf("Enter values of X and y \n");
scanf("%d%d",&x,&y);
p=power(x,y);
printf("%f",p);
getch();
}

OUTPUT
Enter values of X and Y
2
3
8.000000
Enter values of X and Y
2
-2
0.25
Enter values of X and Y
3
0
1

BOMB GAME

/*
REQUEST for all game players :
KEEP NUM LOCK , CAPS , SCROLL LOCK OFF
Lft Shift ==> Move left
Rht Shift ==> Move right
Any Ctrl ==> Fire on Bomb on path.
*/

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
unsigned char far *vidmem=0xB8000000;
void write(unsigned char,unsigned char,unsigned char);
unsigned char read(unsigned char,unsigned char);
void main()
{
unsigned char far *keybmem=0x417;
unsigned char counter=0,destroyed=0,speed=0,bombposx=0,bombposy=0,temp=0,sleeper=250,row,col,curcol=40;
unsigned char bombactive='n';
/*make it boolean later*/
int i,j=0;
clrscr();
printf("REQUEST for all game players :\n\nKEEP NUM LOCK , CAPS , SCROLL LOCK OFF\nLft Shift ==> Move left\nRht Shift ==> Move right\nAny Ctrl ==> Fire on Bomb on path.\n\n\tPress any key to Continue...");
getch();
clrscr();
for(i=0;i<25;i++)
{
write(0,i,32);
write(79,i,32);
}
write(curcol,0,30);
write(0,23,1);
write(79,23,1);
*keybmem=0;
for(;;)
{
if(bombactive=='n'&&counter<26)
{
counter=0;
temp=counter;
for(;;)
{
bombposx=random(80);
if(bombposx>curcol&&bombposx-curcol<20)
break;
else
if(curcol>bombposx&&curcol-bombposx<20)
break;
}
if(bombposx!=0&&bombposx!=79)
{
write(bombposx-1,0,'_');
write(bombposx+1,0,'_');
}
bombposy=24;
write(bombposx,bombposy,31);
bombactive='y';
counter++;
}
if(bombactive=='y'&&counter>25)
{
bombactive='n';
write(bombposx,bombposy,32);
if(bombposx!=0&&bombposx!=79)
{
write(bombposx-1,0,32);
write(bombposx+1,0,32);
}
sound(100);/*UNDESTROYED BOMB HITTING GROUND*/
delay(50);
nosound();
counter=0;
}
if(bombactive=='y'&&counter<26)
{
if((counter-temp)==1)
{
temp=counter;
write(bombposx,bombposy,32);
write(bombposx,bombposy-1,31);
bombposy--;
/*IF ANY PROPAGATION SOUND NEEDED IN MID AIR
But It would become too noisy Hope u dont burn up
your PC's small speaker.*/
/*
sound(16000);
delay(25);
nosound();
*/
}
counter++;
}
for(i=0;i<24;i++)
{
write(0,i,read(0,i+1));
write(79,i,read(79,i+1));
}
if(j==0)
{
write(0,24,2);
write(79,24,2);
j++;
}
else
{
j=0;
write(0,24,1);
write(79,24,1);
}
if(*keybmem==2&&curcol>1)
{
write(curcol,0,32);
write(curcol-1,0,30);
curcol--;
sound(150);/*GUN ON GROUND MOVING LEFT SOUND*/
delay(20);
nosound();
}
if(*keybmem==1&&curcol<78)
{
write(curcol,0,32);
write(curcol+1,0,30);
curcol++;
sound(150);/*GUN ON GROUND MOVING RIGHT SOUND*/
delay(20);
nosound();
}
if((*keybmem==4)&&(bombposx==curcol))
{
counter=0;
bombactive='n';
if(bombposx!=0&&bombposx!=79)
{
write(bombposx-1,0,32);
write(bombposx+1,0,32);
}
write(bombposx,bombposy,32);
sound(40);/*BOMB SUCCESSFULLY BLASTED/INTERCEPTED IN MID AIR SOUND*/
delay(50);
nosound();
destroyed++;
if(destroyed>2)
{
clrscr();
speed++;
destroyed=0;
if(speed>4)
{
sleeper=255;
speed=0;
}
else
{
sleeper=255-(speed*50);
}
printf("\t%c GREAT Going... Time to Change speed ... %c Speed Level : %u of %u ms.",2,2,speed,sleeper);
getch();
clrscr();
curcol=40;
write(curcol,0,30);
}
}
delay(sleeper);
}
}
void write(unsigned char col,unsigned char row,unsigned char ch)
{
*(vidmem+(24-row)*160+col*2)=ch;
}
unsigned char read(unsigned char col,unsigned char row)
{
return *(vidmem+(24-row)*160+col*2);
}

Monday 1 April 2013

FUNCTION WITH ARGUMENTS AND RETURN VALUE

#include<stdio.h>
#include<conio.h>
int largest (int a,int b,int c)
{
int largest;
largest=a;
if(b>largest)
largest=b;
if(c>largest)
largest=c;
return(largest);
}
void main()
{
int a,b,c,lar;
int x,y,z;
clrscr();
printf("Enter value of a,b and c\n");
scanf("%d%d%d",&a,&b,&c);
lar=largest(a,b,c);
printf("Largest =%d\n",lar);
printf("Enter the values of x,y and z \n");
scanf("%d%d%d",&x,&y,&z);
printf("Largest =%d\n ",largest(X,Y,Z));
getch();
}

OUTPUT:
Enter values of a,b and c
3   4   5
Largest=5
Enter values of X,Y and Z
4   5   6 
Largest=6

Explanation
Here as in the case of previous programs the largest()takes three variable a,b and c of int type as formal arguments and finds the largest of the values collected by the argument but unlike in the previous cases it does not display the largest value found out but returns it to the calling function(main()).
In the main(),the values of variables a,b,c are passed in the first call is used on RHS of an assignment statement as 
lar=largest(a,b,c);
The values returned by the function is collected by the variable lar and it is displayed.
In the second call to the function largest(), the values of x,y,z are passed.
Lar=Largest (x,y,z);
As a result the function returns the largest os x,y,z and it is assigned to the variable which is then displayed.