Wednesday, March 12, 2014

Saturday, March 8, 2014

Array Fundamentals (How to store multiple values)

#include<iostream>
using namespace std;
int main()
{
int a[5];
for(int j=1;6>j;j++)
{
cout<<"Enter the age";
cin>>a[j];
}

for(int j=1;6>j;j++)
{
cout<<"you entered"<<a[j]<<endl;
}
return 0;
}

Friday, March 7, 2014

2013 SLIIT Midterm Answers ( IPE_C_Unix_IT101_1a ) Question 02

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a,t,t1;
cout<<"Enter the number: ";
cin>>a;

for(int n=1;n<=a;n++ )
{
t=pow(n,n);
t1=t1+t;
}
cout<<t1;

return 0;
}

Wednesday, March 5, 2014

C++ ( setw ) How to leave a space between two words.

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
cout<<"SriLanka"<<setw(25)<<"Australia"<<endl;
return 0;
}

C++ 2 to the power 3 (Exponent Function)

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
cout<<pow(2,3)<<endl;
return 0;
}

C++ For Loop 1,4,9,16....n

#include<iostream>
using namespace std;
int main()
{
for(int n=0;n<10;n++)
{
cout<<n*n<<endl;
}
return 0;
}

C++ For Loop 10,20,30....n

#include<iostream>
using namespace std;
int main()
{
for(int n=0;n<100;n=n+10)
{
cout<<n<<endl;
}
return 0;
}

C ++ For Loop 1,2,3.....n

#include<iostream>
using namespace std;
int main()
{
for(int n=1;n<10;n++)
{
cout<<n<<endl;
}
return 0;
}


Monday, March 3, 2014

Law and Rules of Boolean Algebra


Commutative Law A+B = B+A
Associative Law A+(B+C) = (A+B)+C
Distributive Law A(B+C) = A.B+A.C

Sunday, March 2, 2014

2013 SLIIT Midterm Answers ( IPE_C_Unix_IT101_1a ) Question 03

#include<iostream>
using namespace std;
int main()

{

int y,a,m,t2,i1,t1,i2;
float r=10.50/100,r2=11.50/100;
cout<<"Interest method: ";
cin>>m;

if (m==1)

{
cout<<"Loan amount: ";
cin>>a;
cout<<"Number of year :";
cin>>y;
i1=a*r*y;
t1=a+i1;
cout<<"Interest amount"<<i1<<endl;
cout<<"Total amount"<<t1<<endl;
}

else if(m==2)
{
cout<<"Loan amount: ";
cin>>a;
cout<<"Number of year :";
cin>>y;
i2=t2-a;
t2=a*r2*y;
cout<<"Total amount :"<<t2<<endl;
cout<<"Interest amount :"<<i2<<endl;
}


else
{
cout<<"Invalid interest metod!";
}
return 0;
}

Saturday, March 1, 2014

Colour coding RJ 45.


  1. Crossover T568A to T568B
  2. Straight through - T568B to T568B  
 MAC and Non Mac
  • MAC -Router and computer
  • Non MAC- HUB, Switch,bridge, printer


  • None MAC to MAC – straight through
  • MAC to MAC // Non MAC to Non MAC - cross over

2013 SLIIT Midterm Answers ( IPE_C_Unix_IT101_1a ) Question 01


#include<ncurses.h>
int main()
{
int a=50;
initscr();
for(int r=5;r<19;r++)
{
for(int c=35;c<41;c++)
{
start_color();
init_pair(1,7,3);
attrset(COLOR_PAIR(1));
move(r,c);
printw("o");
}
}

for(int r=10;r<15;r++)
{
for(int c=41;c<46;c++)
{
start_color();
init_pair(2,0,4);
attrset(COLOR_PAIR(2));

move(r,c);
printw("w");
}
}

for(int r=15;r<19;r++)
{
for(int c=46;c<a;c++)
{
start_color();
init_pair(3,5,2);
attrset(COLOR_PAIR(3));

move(r,c);
printw("M");
}
a--;
}
getch();
endwin();
return 0;
}