Sunday, June 1, 2014

C++ Program to find largest number using function

#include <iostream>
#include <conio.h>
using namespace std;
int max(int , int); // function declaration
int main ()
{
int x; // local variable declaration:
int y;
int ans;
cout<<"Enter the first value:";
cin>>x;
cout<<"Enter the second value:";
cin>>y;
ans = max(x, y); // calling a function to get max value.
cout << "Max value is : " << ans << endl;
getchar();
return 0;
}
int max(int num1, int num2) // function definition
{
int result; // local variable declaration
if (num1 > num2)
result = num1;
else
result = num2;
getchar();
return result;
}



Saturday, May 31, 2014

C++ Program which displays the radius ,area and color of the circle using constructor

#include <iostream>   
#include<conio.h>
#include <string>      // using string
using namespace std;

class Circle {
private:
double radius;      // Data member (Variable)
string color;       // Data member (Variable)

public:
   // Constructor with default values for data members
Circle(double r , string c ) {
radius = r;
color = c;
   }

double getRadius() {  // Member function (Getter)
return radius;
   }

string getColor() {   // Member function (Getter)
return color;
   }

double getArea() {    // Member function
return radius*radius*3.1416;
   }
};   // need to end the class declaration with a semi-colon
 // Test driver function
int main() {
   // Construct a Circle instance
   Circle c1(1.2, "blue");
cout<< "Radius=" << c1.getRadius() << " Area=" << c1.getArea()
<< " Color=" <<c1.getColor() <<endl;

   // Construct another Circle instance
   Circle c2(3.4,"Red"); // default color
cout<< "Radius=" << c2.getRadius() << " Area=" << c2.getArea()
<< " Color=" <<c2.getColor() <<endl;

   // Construct a Circle instance using default no-arg constructor
   Circle c3(5,"Yellow");      // default radius and color
cout<< "Radius=" << c3.getRadius() << " Area=" << c3.getArea()
<< " Color=" <<c3.getColor() <<endl;
getch();
return 0;
}










First Java Program

public class HelloWorld {
   public static void main(String[] args) {
      System.out.println("Hello, World");
   }
}

To compile and run java program open command prompt. Go to the location where the java file is saved. To complie type javac and name of java program. To run java program type java and name of file. In below picture "FirstJava" file is compiled and run by cmd prompt.

C++ Program to print week day according to number by getting number from user

#include<conio.h>
#include<iostream.h>
main()
{
      int num;
      clrscr();
      cout<<"Enter any number between 1 to 7: ";                            
      cin>>num;
      switch(num)
      {
      case 1:
                   cout<<"Monday";
                   break;
      case 2:
                   cout<<"Tuesday";
                   break;
      case 3:
                   cout<<"Wednesday";
                   break;
      case 4:
                   cout<<"Thursday";
                   break;
      case 5:
                   cout<<"Friday";
                   break;
      case 6:
                   cout<<"Saturday";
                   break;
      case 7:
                   cout<<"Sunday";
                   break;
      default:
                   cout<<"INVALID NUMBER!!! Please enter number between 1 to 7";
      }
      getch();
      }






Friday, May 30, 2014

Basic Sytanx of C

Some basic commands you should know while writing program in C .
Let write a C program which prints a line of text.

#include<stdio.h>
int main()
{
printf("This is my first C program");
return 0;
}

stdio.h

While writing program in C you should start with #include<stdio.h>.
This is header file, "stdio" means standard input output header. 

Printf

In C language "printf" command is used to display any message on screen.

scanf

In C language scanf is used to accept the user input from the keyboard. The command of scanf is :
scanf("%d",&base).
Let us take an example. We write a program that will calculate area of triangle and display the answer.
#include<stdio.h>
int main()
{
float area,base,height;
printf("n\Program to calculate the area of triangle");
printf("n\nPlease enter the value of base :")
scanf("%f",&base);
printf("Please enter the value of Height:")
scanf("%f",&height);
area=0.5*base*height;
printf("\n\nHeight=%f",height);
printf("\nBase=%f",base);
printf("\n0.5*Height*Base=Area");
printf("\n0.5*%f*%f=%f\n",height,base,area)'
return 0;
}

"%d" is used for integer data type.
"%f" is used for float data type.
"%c" is used for character data type.
"%s" is used for string data type.

Some other commands to remember

\n

\n is new line character. So whenever you want a newline you have to add a \n.

\t

\(horizontal tab) Moves the active position to the next horizontal tabulation position on the current line.

\a

is alert/bell

How TO Install JDK on Windows

  1. Download the latest version of the *Java JDK from Sun Microsystems.
  2. Install the Java Software Development Kit Step 2.jpg

    Double-click on the install file and it should open an installer (Fig. 1).
  3. Install the Java Software Development Kit Step 3.jpg
    3
    Click next, then read and accept the license.
  4. Install the Java Software Development Kit Step 4.jpg

    On the next screen you will encounter some options. Just leave these alone and click next unless you know what you are doing. (Because this is being read it is assumed that you do not.)(Fig. 2)
  5. Install the Java Software Development Kit Step 5.jpg

    The next page you encounter should install (and in some cases download) the Java Development Kit. (Fig. 3)
  6. Install the Java Software Development Kit Step 6.jpg

    After the installer is finished, open run by clicking Start > Run... or by typing Windows Key + R.
  7. Install the Java Software Development Kit Step 7.jpg

    In the text box, type "cmd" and click "OK".
  8. Install the Java Software Development Kit Step 8.jpg

    A simple window should be opened with a black background and a text prompt. This is called the "Command Prompt." My command prompt background is red, but it could really be any color. (Fig. 4)
  9. Install the Java Software Development Kit Step 9.jpg

    After focusing the window, type "javac" and press enter. If the prompt returns something along the lines of: "'javac' is not recognized as an internal or external command, operable program or batch file" then continue with the next step. If it shows many more options and lines, skip to step 15.
  10. Install the Java Software Development Kit Step 10.jpg

    Open the properties of "My Computer" by either right-clicking the icon on the desktop or right-clicking Start > My Computer. When the pop up menu opens, scroll to the bottom and select "Properties".
  11. Install the Java Software Development Kit Step 11.jpg

    This should open a window named "System Properties". Click on the "Advanced" tab and then click "Environment Variables". (Fig. 5)
  12. Install the Java Software Development Kit Step 12.jpg

    Next, another window opens with a lot of confusing sentences and letters. Double-click on the "Path" variable on either of the option boxes. It is recommended to edit the variable in the box "User variables for (your username)".
  13. Install the Java Software Development Kit Step 13.jpg

    Once the variable is opened, a text box in yet another window appears. Careful not to delete anything in this box. At the end of the text box, add a semi-colon if there is not one already, and add "C:\Program Files\Java\jdk1.6.0\bin" to the text box. This is assuming you did not change the file path of the installation.
  14. Install the Java Software Development Kit Step 14.jpg

    Click "Apply" and "OK" to all the windows you have just opened. Open the command prompt again, while following steps 6-9 to see if that "javac" command works.
  15. Install the Java Software Development Kit Step 15.jpg

    Congratulations! You have succesfully installed JDK on your system.

Saturday, May 10, 2014

PTCL ADSL+3G Evo Router


PTCL introduced its new ADSL + 3G Evo Router in Pakistan.
1) ADSL Modem
2) 3G Evo Router
3) Wireless N150 Mbps 20/40 MHz 4.IPTV via Wifi works like a charm
4) USB storage server
5) Wireless Print Server
6)Guest Wifi SSID