Friday, 31 August 2012

Single Inheritance using C++

#include<iostream.h>
#include<conio.h>
class base
{
protected:int a,b;
public:
void getdata()
{
cout<<"\n Enter A value=";
cin>>a;
cout<<"\n Enter B value=";
cin>>b;
}
};
class derived:public base
{
public:
void putdata()
{
cout<<"\n\n A value="<<a;
cout<<"\n\n B value="<<b;
}
};
void main()
{
derived obj;
clrscr();
cout<<"\n single inheritance:\n";
obj.getdata();
obj.putdata();
getch();
}

Operator overloading (unary) in C++

#include<iostream.h>
#include<conio.h>
class space
{
int x;
int y;
int z;
public:
void getdata(int a,int b,int c);
void display();
void operator-();
};
void space::getdata(int a,int b,int c)
{
x=a;
y=b;
z=c;
}
void space::display()
{
cout<<x<<"\t";
cout<<y<<"\t";
cout<<z<<"\n";
}
void space::operator-()
{
x=-x;
y=-y;
z=-z;
}
void main()
{
space s;
clrscr();
s.getdata(10,-20,30);
cout<<"s:";
s.display();
-s;
cout<<"s:";
s.display();
getch();
}

Operator Overloading Binary operator using C++

#include<iostream.h>
#include<conio.h>
class complex
{
float x,y;
public:
complex()
{
}
complex(float real,float imag)
{
x=real;
y=imag;
}
complex operator+(complex);
void display();
};
complex complex::operator+(complex)
{
complex temp;
temp.x=x+c.x;
tmp.y=y+c.y;
return(temp);
}
void complex::display()
{
cout<<x<<"+g"<<y<<"\n";
}
void main()
{
complex c1,c2,c3;
clrscr();
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"c1=";
c1.display();
cout<<"c2=";
c2.display();
cout<<"c3=";
c3.display();
getch();
}

Wednesday, 29 August 2012

Stack Using List using C programming

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int data;
struct node*link;
};
struct node*top=NULL,*temp;
void main()
{
int choice,data;
clrscr();
while(1)
{
printf("\n1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\n");
printf("\n enter your choice....");
scanf("%d",&choice);
switch(choice)
{
case 1:
temp=(struct node*)malloc(sizeof(struct node));
printf("\n enter a node data...");
scanf("%d",&data);
temp->data=data;
temp->link=top;
top=temp;
break;
case 2:
if(top!=NULL)
{
printf("\n The poped element is %d",top->data);
top=top->link;
}
else
{
printf("\n stack underflow");
}
break;
case 3:
temp=top;
if(temp==NULL)
{
printf("\n stack is empty\n");
}
while(temp!=NULL)
{
printf("(%d)",temp->data);
temp=temp->link;
}
break;
case 4:
exit(0);
}
}
}

Friday, 24 August 2012

Tracking Big Foot: Why GPS Location Requires a Warrent

 In a case that raises as many questions as the average sighting of Big Foot, a panel of the Sixth Circuit Court of Appeals ruled earlier this week that law enforcement officers didn't need a warrant to obtain GPS location information generated by his cell phone.

The court’s analysis has been roundly criticized as legally incorrect, lazy, shallow, and vague. I’d like to focus on one aspect of the case that the court missed:  the Department of Justice recommends that police obtain warrants in the scenario presented by this case, does so for good reason, and there were sufficient facts for the government to obtain the warrant that the Department of Justice recommends investigators obtain.

In this case, U.S. v. Skinner law enforcement officers obtained an order that allowed them to monitor for 60 days the location of a pre-paid cell phone they had good cause to believe was being used by Big Foot, the nickname given trucker eventually identified as Melvin Skinner, who they alleged was transporting marijuana.  They obtained a court order under which the provider, Sprint/Nextel, acting at the behest of law enforcement, pinged the phone repeatedly so it would reveal its location over a three-day period and eventually activated the phone’s GPS functionality to locate the phone’s GPS coordinates.   (Sprint/Nextel recently developed a web portal through which law enforcement can do this automatically for the duration of the court authorization, without contacting the provider each time officers ping the phone.)

The court found that there was "… no Fourth Amendment violation because Skinner did not have a reasonable expectation of privacy in the data given off by his voluntarily procured … cell phone."  But, as Jennifer Grannick points out cell phones don’t normally "give off" the kind of GPS location data that law enforcement used to locate Skinner.  Unless the user is employing location services – and Skinner wasn’t – the GPS location data has to be created.  In this case, the provider, under court order, remotely activated the GPS function of Skinner's phone so the police could track him.
There's a critical difference between GPS location information and cell tower location information a mobile phone creates during normal use.  The GPS data in this case is created at the request of law enforcement for tracking purposes and not through the normal use of the mobile phone. The GPS data doesn’t even exist until the provider prompts the device to deliver its GPS location to the provider so law enforcement can access it.  In contrast, providers maintain cell tower location information for business reasons.  Because providers do not normally maintain GPS location information and because it was not voluntarily conveyed to the provider, it is not a "business record" and does not fit into the third party records doctrine, which says that a person has no Fourth Amendment interest in information that is voluntarily revealed to, and held by, a third party.  While the third party doctrine should probably be re-examined, for now we have to live with it, but not for GPS data created by providers at the behest of law enforcement.  For that data, we retain our Fourth Amendment rights against warrantless GPS tracking.

Blind Eye to Justice

Apparently recognizing that GPS is different, the Justice Department recommends that prosecutors obtain a warrant to get GPS location information from mobile communications service providers.  For example, in this power point presentation the Associate Director of the Justice Department Office of Enforcement Operations recommends that prosecutors use search warrants to get prospective GPS location information (referred to as “lat/long data” or latitudinal and longitudinal data) for constitutional, not statutory reasons, and because "anything less presents significant risks of suppression."  In addition, the Justice Department Associate Deputy Attorney General, testified in April last year that when the government seeks to compel disclosure of prospective GPS coordinates generated by cell phones, it relies on a warrant.

The Sixth Circuit missed this point entirely.  It blithely rejected Skinner's Fourth Amendment claims and implicitly bought into the government's argument that orders under the Stored Communications Act provision at 18 USC 2703(d) can be used to obtain prospective location information that has never been stored.  It did not consider whether the information sought was within the third party records doctrine and it cited no statutory authority for the proposition that the government can compel a provider to create the GPS information for the government to seize.

Perhaps most ironically, it seems pretty clear that the government had facts establishing probable cause and could have obtained a warrant if it had applied for one.  As the concurring opinion in Skinner noted, law enforcement officials were watching the drug operation for months, had recorded conversations about an upcoming drug run, learned that the courier was carrying a particular phone that they could track, and that a half ton of marijuana was in transit.

A warrant requirement for location information, as advocated by the Digital Due Process coalition, would still mean a drug courier like Skinner would get caught.  If followed, a statutory warrant requirement decreases the chances a criminal would elude jail because the seized evidence would not be at risk of suppression, as it is now for Big Foot if he appeals this decision

Constructor Overloading in C++

#include<iostream.h>
#include<conio.h>
class cse
{
int m,n;
public:
cse()
{
cout<<"\n the default constructor is executed";
}
cse(int a)
{
m=a;
cout<<"\n the value for a is..."<<m;
}
cse(int a,int b)
{
m=a+b;
cout<<"\n the sum of 20 and 30 is..."<<m;
}
~cse()
{
cout<<"\n destructor is executed";
}
cse(cse&i)
{
m=i.m;
cout<<"\n the value of m is"<<m;
}
};
void main()
{
clrscr();
cse a;
cse x(10);
cse y(20,30);
cse z(y);
getch();
}

Constructor and Destructor in C++

#include<iostream.h>
#include<conio.h>
class cse
{
int m,n;
public:
cse()
{
m=0;
n=0;
}
cse(int a,int b)
{
m=a;
n=b;
}
void display()
{
cout<<"\nm="<<m;
cout<<"\nn="<<n;
}
~cse()
{
cout<<"\n destructor is executed";
}
};
void main()
{
cse a;
clrscr();
cse a2(10,20);
a.display();
a2.display();
getch();
}

Wednesday, 22 August 2012

                singly linked list using list


to download file : click me!

Friday, 10 August 2012

Pointer to members using C++

#include<iostream.h>
#include<conio.h>
class M
{
int x,y;
public:
void setxy(int a,int b)
{
x=a;
y=b;
}
friend int sum(M m);
};
int sum(M m)
{
int M::*px;
px=&M::x;
int M::*py;
py=&M::y;
M *pm;
pm=&m;
int s,s1,s2;
s1=m.*px;
s2=pm->*py;
s=s1+s2;
return s;
}
int main()
{
M n;
void (M::*pf)(int,int)=&M::setxy;
(n.*pf)(10,20);
n.setxy(10,20);
cout<<"the sum is"<<sum(n);
M *op;
op=&n;
(op->*pf)(30,40);
cout<<sum(n);
getch();
return 0;
}

Wednesday, 8 August 2012

Linked list Using C programming

#include<stdio.h>
#include<conio.h>
#define a[30]
int*roll=NULL,top=-1;
void createlist();
void insertlist();
void deletelist();
void viewlist();
void displaymenu();
void creatememory();
void removememory();
void main()
{
int ch;
clrscr();
creatememory();
displaymenu();
while(1)
{
printf("\n");
scanf("%d",&ch);
switch(ch)
{
case 0:
displaymenu();
break;
case 1:
createlist();
break;
case 2:
insertlist();
break;
case 3:
deletelist();
break;
case 4:
viewlist();
break;
default:
removememory ();
printf("\n End of run of your program");
exit(0);
}
}
}
void displaymenu()
{
printf("\n Basic operation in linear list");
printf("\nmenu");
printf("\n\t1.create list");
printf("\n\t2.insert");
printf("\n\t3.delete");
printf("\n\t4.view list");
printf("\n\t5.exit");
printf("\n\t ENTER YOUR CHOICE");
}
void createlist()
{
char ch;
do
{
printf("\n ENTER THE VALUE TO BE INSERTED");
scanf("%d",&ch);
}
while((ch=='y')||(ch=='Y'));
}
void insertlist()
{
int i;
if(top==roll[30])
{
printf("\n The linear list is full");
return;
}
top++;
for(i=top;i>0;i--)
roll[i]=roll[i-1];
printf("\nEnter the element to added");
scanf("%d",&roll[0]);
}
void deletelist()
{
int i,deleteddata;
if(top==-1)
{
printf("\n Linear list is empty");
return;
}
top--;
deleteddata=roll[0];
for(i=0;i<=top;i++)
roll[i]=roll[i++];
printf("\n DELETED data is %d\n",deleteddata);
}
void viewlist()
{
int i;
if(top==-1)
{
printf("\nlinear list is empty");
return;
}
printf("\n element:");
for(i=0;i<=top;i++)
printf("\nenter the element....%d",roll[i]);
}
void creatememory()
{
roll=(int*)malloc(sizeof(int*));
}
void removememory()
{
free(roll);
roll=NULL;
}

queue in C programming

#include<stdio.h>
#include<conio.h>
int arr[20],front=-1,rear=-1,i;
void enqueue();
void dequeue();
void display();
void main()
{
int ch;
clrscr();
do
{
printf(" [1] enqueue \n [2] dequeue \n[3] display \n[4] exit\n ");
printf("\n enter your choice ");
scanf("%d",&ch);
switch (ch)
{
case 1:
enqueue ();
break;
case 2:
dequeue ();
break;
case 3:
display ();
case 4:
break;
default:
printf("\n invalid option ");
getch();
}
}
while (ch!=4);
getch();
}
void enqueue()
{
if(rear==20-1)
{
printf("\n queue is full");
getch();
return;
}
rear++;
printf("\n enter element to enqueue ");
scanf("%d",&arr[rear]);
if(front==-1)
front++;
}
void dequeue()
{
if (front==-1)
{
printf("\nqueue is empty");
getch();
return;
}
printf("\n the deque element is %d",arr[front]);
getch();
if (front==rear)
front=rear=-1;
else
front++;
}
void display()
{
if (front==-1)
{
printf("\n the queue is empty");
getch();
return;
}
printf("\n the elements in queue are front");
for(i=front;i<=rear;i++)
printf("\n the elements in queue are %d",arr[i]);
getch();
}

Stack using C programming

#include<stdio.h>
#include<conio.h>
void add();
void del();
void display();
void exit();
int n,a[10],i,j,k=-1;
void main()
{
clrscr();
do
{
printf("\n1.ADD");
printf("\n2.DELETE");
printf("\n3.DISPLAY");
printf("\n0.EXIT");
printf("\n\nEnter your choice:\t");
scanf("%d",&n);
switch(n)
{
case 1:add();
break;
case 2:del();
break;
case 3:display();
break;
case 0:
break;
}
}
while(n!=0);
}
void add()
{
if(k<9)
{
printf("\n enter the elements to be inserted...\n");
scanf("%d",&i);
k++;
a[k]=i;
}
else
{
printf("\n stack is fill!");
}
}
void del()
{
if(k==-1)
{
printf("\n stack is empty!");
}
else
{
i=a[k];
k--;
printf("\n deleted element is...%d",i);
}
}
void display()
{
if(k==-1)
{
printf("\n no value");
}
else
{
int j=k;
printf("\n element stored as:\n");
for(j=k;j>=0;j--)
{
printf("%d",a[j]);
printf("\n");
}
}
}
There was an error in this gadget