Saturday, October 11, 2014

C program to check a year whether it is leap year or not


The C program given below is a program that will ask you a year showing a message Enter a year: . When you will input a year using the keyboard, then the program will check whether it is a leap year or not. Most of the description of the codes are given after the statement in different color. Ignore the description when you will type the program in a compiler like Turbo C, CodeBlocks etc.
c program,leap year program

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

main()
{
int year; /*Declaring an integer type variable called year*/

printf("Enter a year: "); /*Showing a message*/
scanf("%d",&year); /*Getting value from keyboard*/

if(year%4==0) /*Checking if the data is divisible by 4*/
{
printf("The year is leap year"); /*If the year is divisible by 4, then showing a message*/
}

else
{
if(year%100==0) /*Again checking, if the data is divisible by 100*/
    {
if(year%400==0) /*Again checking, if the data is divisible by 400*/
{
     printf("the year is leap year"); /*If the year is divisible by 100 and 400, then showing a message*/
}
    }

else
printf("the year is not leap year"); /*If all the conditions are wrong, then showing a message*/
}
getch();
}



Friday, October 10, 2014

Responsive Menu 04: Adding a clickable button to the responsive menu


In the previous post we make the menu responsive. Now we will add a clickable button to control the menu. And we will also add mouse hover effect for better looking. Let's follow the steps to do so.

 Step 01  Add some more codes inside of the @media section
To add the clickable button, we need to add the line <span class="nav-btn"></span> just after the opening <body> tag of the menu.html page. Then open the menu.css file and add the codes given below after the existing codes inside of @media section.

.nav-btn {
        display: block;
        background-color: #333;
        color: #fff;
        font-family: 'helvetica neue', helvetica;
        font-size: 14px;
        text-align: left;
        cursor: pointer;
        padding: 5px;
    }

    .nav-btn:before {
        content: "Menu";
    }

 Step 02  Save the CSS file and reload the menu.html file
Now save the menu.css file and reload or reopen the menu.html file. Then we will get a menu as like as the image below.

 Step 03  Change the background color and the font
We need some more customization for the main menu. Change the background-color to #333 and add the line font-family: 'helvetica neue', helvetica; , then the font will look more beautiful as like as the image given below..

#menu{
background-color: #333;
font-family: 'helvetica neue', helvetica;
}

After changing the background color

 Step 04  Let's add hover effect to the menu
Still there is no any hover effect added to the menu. To add hover effect, we need to add the codes given below. The codes should placed before the @media section. After adding the codes, save the menu.css file and reload the menu.html file. Then you will get the effect as shown in the image below.

#menu li:hover{
background: #ef1c25;
}


Tuesday, October 7, 2014

Run your first assembly program in DOSBox


From the previous post we have learned to install DOSBox and to configure it so that we can run the programs written in Assembly Language. Now we have to write the hello world program and need to run that program using DOSBox.

 Step 01  Open notepad or any other text editor
First of all we need to open Notepad or any other text editor. To open notepad press Windows Key+R and then type Notepad into the command box, finally press the Enter Key.

 Step 02  Type the program given below
Now type the codes given below...

.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'Hello World!$'

.CODE
MAIN PROC

MOV AX,@DATA
MOV DS,AX

LEA DX,MSG
MOV AH,9
INT 21H

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

 Step 03  Click on Save As...
Now we need to save the text document with .asm extension. That's why we need to click on File from the menu, then we need to click on Save As... as shown in the image below.

 Step 04  Save the file with .asm extension into the folder 8086
After clicking on Save As... , a pop-up window will open as the image given below. Now we have to provide our expected name with .asm extension and most importantly we have to save the .asm file into the directory Local Disk(C:)>8086.

 Step 05  Run the DOSBox and mount the C Drive
Now we need to run DOSBox to execute our hello world program. After running the program we will get a window like the image below. Then we need to type mount c c:/8086 and need to press the Enter Key.
After pressing the Enter Key there will appear a message Drive C is mounted as local directory c:/8086\.

 Step 06  Type c: and press the Enter Key
In this step we have to type c: and need to press the Enter Key again.

 Step 07  Run the hello world program
Now type masm hello.asm and press the Enter Key several times till appearing c:\>. Then type link hello and again press the Enter Key several times till appearing c:\>. Finally type the file name hello and press the Enter Key, then the Hello World! message will appear on the screen.