#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int i,n,max,min,total,sum;
float avg;
printf("Enter Total number of elements \n");
cin>>total;
cout<<"Enter number \n";
cin>>n;
max=n;
min=n;
sum=n;
for(i=1;i<=total-1;i++)
{
cin>>n;
if(n>max)
max=n;
else if(n<min)
min=n;
sum+=n;
}
printf("\n The largest number is %d",max);
printf("\n The smallest number is %d",min);
printf("\n The average number is %f",avg=(sum/total));
return 0;
}
TCP and UDP or TCP over IP or TCP/IP both are protocols. They are the transport layer protocol. TCP is a connection-oriented protocol, on the other hand UDP is a connectionless protocol. Both of them are protocols used for sending bits of data. This is known as packets over the Internet.
They both build on top of the Internet protocol. TCP and UDP are not the only protocols that work on top of IP. Yet, they are the most widely used. Besides, whether you are sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are pickled correspondingly, as they are accelerated from your computer to intermediary routers and on to the end point. The widely used term known as “TCP/IP” mean as to TCP over IP. UDP over IP could just as well be referred to as “UDP/IP”, but this is not a common term.
TCP
TCP stands for Transmission Control Protocol.
TCP Communication between source to destination computer:
When you want to load a web page, your computer sends TCP packets to the web server’s address. During this asking it to send the web page to you. The web server responds by sending a stream of TCP packets. This is your web browser sews up together to form the web page and display it to you.
When you click a link, sign in, post, or a comment, or do anything else, your web browser sends TCP packets to the server. In additionally, the server sends TCP packets back. TCP is not just one way communication. The remote system sends packets back to acknowledge it is received your packets.
TCP guarantees the recipient will receive the packets accordingly by numbering them. The recipient sends messages back to the sender saying it received the messages. If the sender does not get a correct response, it will resend the packets. This process is use to ensure the recipient received them.
Packets are also checked for errors. This reliability is that packets sent with TCP are tracked so no data is lost or corrupted in transit. This is why file downloads do not become corrupted even so there are network hiccups. If the recipient is completely offline, your computer will give up. Additionally you will see an error message saying it cannot communicate with the remote host.
UDP
UDP stands a datagram is the same thing as a packet of information. The UDP protocol works similarly to TCP, though it tosses all the error-checking stuff out. All the back-and-forth communication and deliverability guarantees slow things down.
UDP Communication between source to destination computer:
When using UDP, packets are just sent to the recipient. The sender will not wait to make sure the recipient received the packet; it will just continue sending the next packets. If you are the recipient and you miss some UDP packets, you cannot ask for those packets again. There is no guarantee you are getting all the packets and there is no way to ask for a packet again if you miss it. But losing all this overhead means the computers can communicate more quickly. UDP is used when speed is desirable and error correction is not necessary. For instance, it is frequently used for live broadcasts and online games.
TCP vs UDP or Difference between TCP and UDP protocol
TCP(Transmission Control Protocol)
TCP establishes connection between the computers before transmitting the data
Connection Oriented type protocol
Speed is slow
Highly Reliable
Header size is 20Bytes
It takes acknowledgement of data and has the ability to retransmit, if the user requests.
UDP(User Datagram Protocol)
UDP stands the data directly to the destination computer without checking the system is ready or not.
Connection type is connectionless
Fast in speed
Unreliable
Header is 8Bytes
Neither it takes acknowledgement nor it retransmits the lost data.
Find each convex hull for each area then select that convex hull whether a Missile falls inside it.Make aggregation of the area among the selected convex hull.
#include <stdio.h>
long int arr[1000002];
void array ()
{
long int k=0,i;
arr[3]=0;
for( i = 4; i <= 1000000; i++)
{
k = k + ((i-2)/2);
arr[i] = arr[i-1] + k;
}
}
int main()
{
//array();
long int n;
array();
while(scanf("%ld",&n) && n >= 3)
printf("%ld\n",arr[n]);
return 0;
}