Tuesday, 30 July 2013

Example of HTML PHP Comment

Type the following code in your text editor..

<HTML>
<HEAD>
<TITLE>Example of Comments</TITLE>
</HEAD>
<BODY>
<!-- html comment style -->

<?
// This is a single line PHP comment style.

# Shell type comment style.
/* This is a C style comment, we can use it for multiple lines 

this is suitable for multiple line comment */
?>

</BODY>
</HTML>


Now save this file as comment.php

Comment in PHP

Various types of syntax are used  to add comment in PHP.

Syntax 1

// this is single line comment in php code.

Syntax 2

# this is another style of comment in php code called shell-style.

Syntax 3


/* this is C-style comment in php code used for upto two lines */

Syntax 4

<!   example of html comment which is ignored by browser  >

Sunday, 28 July 2013

Print Quotient and Remainder in C++

// Write a C++ program that takes two values of x(dividend) and
// y(divisor) from user and prints quotient and remainder of x/y

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int x,y,q,r;
    cout<<"Enter dividend number x : ";
    cin>>x;
    cout<<"Enter divisor number y : ";
    cin>>y;

    cout<<"\n\n------------------------------------\n";
    cout<<" Quotient and Remainder of x/y \n";
    cout<<"------------------------------------\n";

    q = x / y ;
    r = x % y;
    cout<<"Quotient  = "<<q<<endl<<"Remainder = "<<r;
    getch();
}


Saturday, 27 July 2013

PHP Start and End tags

There are three basic types of PHP Start and End tags which is also called PHP Opening and Closing tags respectively.


Figure: PHP Starting and Ending Tags


Examples:

You can use any type of php tag in your script.

<?
echo "<P>Example of 1st type of PHP tag.</P>";
?>


<?php
echo "<P>Example of 2nd type of PHP tag.</P>";
?>


<script language="php">
echo "<P>Example of 3rd type of PHP tag.</P>";
</script>


Wednesday, 24 July 2013

Even Numbers in Descending Order

// Write a C++ program that prints odd numbers in
// descending order from a given range.

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int i,n;
    cout<<"Enter any number : ";
    cin>>n;
   
    cout<<"\n\n------------------------------------\n";
    cout<<" Even numbers in Descending Order \n";
    cout<<"------------------------------------\n";

    if( n%2 != 0 )
    n--;
    for( i = n ; i >= 0 ; i = i-2 )
    cout<<"         "<<i<<endl;
    getch();
}

Sunday, 21 July 2013

Even Numbers in Ascending Order

// Write a C++ program that prints even numbers in
// ascending order up to given range.


#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int i,n;
    cout<<"Enter any number for ending range : ";
    cin>>n;
   
    cout<<"\n\n------------------------------------\n";
    cout<<" Even numbers in Ascending Order \n";
    cout<<"------------------------------------\n";

    for( i = 0 ; i <= n ; i = i+2 )
    cout<<"         "<<i<<endl;
    getch();
}

Odd Numbers in Ascending Order

// Write a C++ program that prints odd numbers in
// ascending order up to given number.

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int i,n;
    cout<<"Enter any number : ";
    cin>>n;
   
    cout<<"\n\n------------------------------------\n";
    cout<<" Odd numbers in Ascending Order \n";
    cout<<"------------------------------------\n";

    if( n%2 == 0 )
    n--;
    for( i = 1 ; i <= n ; i = i+2 )
    cout<<"         "<<i<<endl;
    getch();
}