Saturday, November 26, 2011

Difference Between TCP and UDP Protocols

TCP and UDP both are transport layer protocol. They both use for process to process communication. Here I am going to discuss about "Difference Between TCP and UDP Protocols".



What is the Difference Between TCP and UDP Protocols?

1. TCP is a Transmission Control Protocol and UDP is a User Datagram Protocol.

2. TCP is a connection-oriented protocol but UDP is a connection-less protocol.
Connection-oriented means there is first establish connection before transmission and after transmission connection release.
In connection-less there is no need to call setup and call release. There is not send acknowledgement from receiver side so not detection of errors.

3. TCP is a reliable protocol but UDP is a unreliable protocol.

4. TCP packet is called as segment but UDP packet is called as datagram.

5. TCP is used for reliable and large data transfer from source to destination but UDP is used for small message transfer between stations and does not much care about reliability.

6. TCP supports error control but UDP does not support error control.

7. TCP is powerful protocol but UDP is a powerless protocol.

8. TCP is a Heavyweight protocol but UDP is a Lightweight protocol.

9. In TCP, there are control transmission of segment if any segment is loss then retransmit from source to destination but In UDP there is not retransmit loss datagram.

10. In TCP segment transfer in a sequence but In UDP there is not any sequence or order of data transmission.

11. TCP transmission speed is slower than UDP protocol.


Examples: TCP used in WWW, web services, HTTP, FTP, Telnet, IMAP etc.
UDP used in buffering of online audio and video, DNS, online games and other multimedia application where transmission speed matters more than completeness etc.

Tuesday, November 22, 2011

C Program to Swap Two Numbers

It is a sample c program to swap two number.

Program Source Code


#include"stdio.h"
#include"conio.h"
void swap(int,int);
void main()
{

int a,b;
clrscr();
printf("\n Enter value of a:-");
scanf("\n%d",&a);
printf("\n Enter value of b:-");
scanf("\n%d",&b);
printf("\n\n a before swapping is:--%d",a);
printf("\n\n b before swapping is:--%d",b);
swap(a,b);
printf("\n\n a after swapping is:--%d",a);
printf("\n\n b after swapping is:--%d",b);
getch();

}
void swap(int x,int y)
{
int t;
t=x;
x=y;
y=t;
printf("\n\n a in swapping is:--%d",x);
printf("\n\n b in swapping is:--%d",y);
}

Output


c program to swap two number

C Program to Calculate Factorial of a Number

It is a sample c program to calculate factorial of a number.

Program Source Code


#include"stdio.h"
#include"conio.h"
void main()
{
int fact=1,i,n;
clrscr();
printf("\n ***FIND THE FACTORIAL NUMBER OF ANY
NUMBER***");
printf("\n Enter the value of n:--");
scanf("\n %d",&n);
for(i=1;i<=n;i++)
{
fact=fact*i;
printf("\n factorialis:-- %d",fact);
}
getch();
}

Output


Calculate Factorial of a Number

C Program to Check Largest Number in Two Variable

It is a sample C program to check largest number in two variable.

Program Source Code


#include"stdio.h"
#include"conio.h"
void main()
{
int a,b;
clrscr();
printf("***PRINT LARGEST VALUE AMONG TWO OR MORE
NUMBER***");
printf("Enter the value of a:--");
scanf("%d",&a);
printf("Enter the value of b:--")
scanf("%d",&b);
if(a>b)
{
printf("a is greater");
}
else
{
printf("b is greater");
}
getch();
}

Output


Largest Number in Two Variable in C Program