Wednesday 6 January 2016

Its a lazy Holiday morning

Particularly I dont know what these Polish people are celebrating, anyway, here is the code for factorisation and checking for a prime number. for the primorial... i got lazy, and stuck probably... but I know y'all geniouses and you can finish it..hehe

dont forget to type exit to quit.

 
#include <iostream>
int fact(int);
bool is_prime(int);
int primorial(int);

using namespace std;

int main()
{
    string choice;
    int a;
    while(choice!="exit"){
    cout << "Choose a code to test" << endl;
    cout << "CODE\t|\tDescription" << endl;
    cout << "fact\t|\tCalculates Factorial" << endl;
    cout << "prime\t|\tChecks if your number is prime or not" << endl;
    cout << "primo\t|\tDescription" << endl;
    cout << "exit\t|\tQuits the program" << endl;
    cin  >>  choice;

        if(choice=="fact"){
        cout << "Enter a number to factorize\n";
        cin  >> a;
        cout << "\nThe factorial is " << fact(a) << endl;}

        if(choice=="prime"){
        cout << "Enter a number\n";
        cin  >> a;
        if(is_prime(a))
            cout <<a<< " is a prime number.\n\n";
        else
            cout <<a<< " is not a prime number.\n\n";}

        if(choice=="primo"){
        cout << "Enter a number to primorialize\n";
        cin  >> a;
        cout << "The primorial is " << primorial(a)<<endl<<endl;}

    }

    return 0;
}


int fact(int x)
{
    if(x==1)
        return x;
    else
        return x*fact(x-1);
}


bool is_prime(int x)
{
    if(x==1)
    return true;
    if(x==2)
    return true;
    for(int y=2; y<x ; y++){
        if(x%y==0)
        return false;
        else
        return true;}
}

int primorial(int x)
{
 ////////smart people.. i need help!!!
}

Tuesday 5 January 2016

IT Work Environment

.
.
.
.
.
In creating a Html, the server needs the file index.html for accessing the file. This file should be in the folder ../public/..
The group permissions for public is x for www.data for execution

Creating the simplest form of a homepage using one line...lol almost nothing in it..
- create the folder "public_html"
- set the permission to be executed
- create a "index.html" in that folder and open it with a text editor
- write the following html code...

<HTML>
<BODY>
Hellow world
</BODY>
</HTML>

nb: html might
- give the file permission 744
- to access this homepage...in your web browser..navigate to your server, and to your username
- in our case... it xor.uni.lodz.pl/~username

To style your text
<HTML>
<HEAD>
<META CHARSET="UTF-8">
</HEAD>
<BODY>
Hellow world
</BODY>
</HTML>

notice the position of the "tag HEAD"
It should be included after before the body. UTF-8 is used for localized characters, in this case, its the best for Polish chars.

Creating an Interactive Table

In the Body write the following html code

<TABLE WIDTH="960" BORDER="1" ALIGN="CENTER">
<TR> <TD ALIGN="CENTER" COLSPAN="2"> Header text </TD> </TR>
<TR> <TD WIDTH="200" HEIGHT="300" VALIGN="TOP"> </TD>
<TD VALIGN="CENTER"> </TD> </TR>
<TR> <TD COLSPAN="2"> </TD> </TR>
</TABLE>

TD- creates a new cell
WIDTH="960"- can also be writen as a percent e.g WIDTH="80%" according to the screen size

--end of lesson--