Tuesday, 9 July 2013

Bridge

A bridge segment or divide a network to isolate traffic related problem.

A bridge sends the data frames only to the concerned segment.

Bridges are used to connect dis-similar network like ethernet system to Token Ring-System. Thus bridge used to join network using CSMA/CD access and token passing access.

Bridge in Networking
Figure: Bridge in Networking 

Bridge are both hardware and software devices.


Bridge operate "Date Link Layer" in OSI model.

The purpose of bridge as :

  1. Isolate network by MAC addresses.
  2. Manage network traffic by filtering packet.
  3. Translate from one protocol to another.


Monday, 8 July 2013

Hub

Hubs are also called "Multi port repeaters" or "concentrators".

Hub is hardware devices.

Hubs in Computer Networking
Figure: Hubs in computer networking

Hub is similar to repeaters, except that it broadcast data received by any port to tall other parts on the hub.


Hubs are used to provide a physical star topology.

Hubs operators at "Physical layer" in OSI model.



Sunday, 7 July 2013

Random Number Pyramid

Q. Write a C program to print the any entered number, digit pyramid,

For example:

if entered number is : 87954
then output must be as:

87954
7954
954
54
4

Ans.

/*c program for random digit pyramid*/
#include<stdio.h>
int main()
{
 int n[50],i,j=0,k,r,c,len;
 printf("Enter total length of number : ");
 scanf("%d", &len);
 printf("\nNote: Entered digit MUST be single.\n\n");
 for(i=0; i<len; i++)
 {


   printf("Enter %d single digit : ",i+1);
   scanf("%d", &n[i]);
 }
 printf("\n");
 for(r=1; r<=len; r++,j++)
 {
  for(c=r,k=j; c<=len; c++,k++)
     printf("%d",n[k]);
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:



Output of Random Number Pyramid C program
Figure: Screen shot for Random Number Pyramid C program


Wednesday, 3 July 2013

Diamond Pattern C program

Q. Write a C program to print the following diamond pattern as:

4
434
43234
4321234
43234
434
4

Ans.

/*c program for diamond pattern*/
#include<stdio.h>
int main()
{
 int num,r,c,z,n,nm,no;
 printf("Enter max. number : ");
 scanf("%d", &num);
 nm = num+1;
 for(r=1; r<=num; r++,nm--)
 {
  for(c=1,n=num; c<=r; c++,n--)
     printf("%d",n);
  for(z=nm,c=1; c<r; c++,z++)
     printf("%d",z);
  printf("\n");
 }

 no = num-1;
 for(r=1; r<=num; r++,no++)
 {
  for(c=num; c>r; c--)
     printf("%d",c);
  for(z=no,c=num-2; c>=r; c--,z++)
     printf("%d",z);
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of diamond pattern C program
Figure: Screen-shot for diamond pattern C program


Number Triangle

Q. Write a C program to print the following number triangle/pyramid program:

1
12
123
1234
123
12
1

Ans.

/*c program for number triangle*/
#include<stdio.h>
int main()
{
 int num,n,r,c,z;
 printf("Enter max. number : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
   for(c=1; c<=r; c++)
     printf("%d",c);
   printf("\n");
 }

 for(r=1; r<num; r++)
 {
   for(c=num,z=1; c>r; c--,z++)
     printf("%d",z);
   printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of number triangle C program
Figure: Screen-shot for number triangle C program


Number-Character Pattern

Q. Write a C program to print the following number-character pattern as:

1111111
1A1AAAA
1AA1AAA
1AAA1AA
1AAAA1A
1AAAAA1
1111111

Ans.

/*c program for number-character pattern*/
#include<stdio.h>
int main()
{
 int num=7,r,c,z;
 printf("1111111\n");
 for(r=1; r<=5; r++)
 {
  for(c=1; c<=num; c++)
  {

   if(c==1)
     printf("1");
   else
   {
     if( (r==1 && c==3) || (r==2 && c==4) || (r==3 && c==5) || (r==4 && c==6) || (r==5 && c==7) )
        printf("1");
     else
        printf("A");
   }
  }
  printf("\n");
 }
 printf("1111111");
 getch();
 return 0;
}

The output of above program would be:


output of Number-Character pattern C program
Figure: Screen-shot for number-character pattern C program

 

Odd Number Pyramid

Q. Write a C program to print the following odd number pyramid as:

1
3 5
5 7 9
7 9 11 13

Ans.

/*c program for odd number pyramid*/
#include<stdio.h>
int main()
{
 int num,r,c,z=1,p;
 printf("Enter no. of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++,z=z+2)
 {
  for(c=1,p=z; c<=r; c++,p=p+2)
      printf(" %d",p);
  printf("\n");
 }

 getch();
 return 0;
}

The output of above program would be:


output for odd number pyramid C program
Figure: Screen-shot for odd number pyramid C program