Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Keyboard ProgrammingRSS Feeds

Program to show the Keyboard Status

Posted By: Easy Tutor     Category: C Programming     Views: 5297

Write a program to show the Keyboard Status.

Code for Program to show the Keyboard Status in C Programming

 # include <stdio.h>
 # include <conio.h>
 # include   <dos.h>

 int main( )
 {
    int iCount=15;
    int iMaxValue=128;
    unsigned char far* ptrKeyboard=(unsigned char far*)0x00400017;

    clrscr( );

    printf("\nKeyboard Status Byte (Hex) = %X",*ptrKeyboard);
    printf("\nKeyboard Status Byte (Binary) = ");

    for(iCount=7;iCount>=0;iCount--)
    {
       if(iCount==3)
      printf(" ");

       if((*ptrKeyboard&iMaxValue)==iMaxValue)
      printf("1");

       else
      printf("0");

       iMaxValue/=2;
    }

    printf("\n\nWhere:");
    printf("\n Bit 7    Insert");
    printf("\n Bit 6    Caps Lock");
    printf("\n Bit 5    Num Lock");
    printf("\n Bit 4    Scroll Lock");
    printf("\n Bit 3    Alt Key");
    printf("\n Bit 2    Ctrl Key");
    printf("\n Bit 1    Left Shift");
    printf("\n Bit 0    Right Shift");

    getch( );
    return 0;
 }
  
Share: 


Didn't find what you were looking for? Find more on Program to show the Keyboard Status Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Program to show the Keyboard Status is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Joachim Stephan from United Kingdom Comment on: Oct 31
can you check this for me please



#include <stdio.h>
#include <stdlib.h>
#define row 3
#define column 3

void main()
{
int A[row][column], B[row][column], C[row][column];
int i,j,k;
int choice;

for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
printf("enter values in matrix A");
scanf("%d",&A[i][j]);
}
}

for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
printf("enter values in matrix B");
scanf("%d",&B[i][j]);
}
}


printf("choose one of the following:\n");
printf("1. ADDITION:\n");
printf("2. SUBSTRACTION:\n");
printf("3. MULTIPLICATION:\n");

printf("%d",choice);
scanf("%d",&choice);

if(choice==1)
{
//ADDITION
for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
C[i][j]=A[i][j]+B[i][j];
}
}
}

else if(choice==2)
{
//SUBSTRACTION
for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
C[i][j]=A[i][j]+B[i][j];
}
}
}

else if(choice==3)
{
//MULTIPLICATION

for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
C[i][j]=0;

for (k=0;k<3;++k)
C[i][j]=C[i][j]+(A[i][j]*B[i][j]);
}
}
}

else
if (choice==4)
printf("Invalid Operation:\n");
}


//RESULT

/*printf("the resultant matrix is C",C);
for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
{
C[i][j]
printf("C is %s",C);
}
}
system("pause");
}*/



View All Comments