Sunday, 22 February 2015

Friday, 20 February 2015

Create an Image Play – Pause Slide Show using Javascript.

//Create an Image Play – Pause Slide Show.

CSS Code

#container
{
height: 630px;
width: 1330px;
float: left;
}
#box
{
height: 400px;
width: 1000px;
float: left;
margin: 120px 165px;;
//margin-right: auto;
border: 1px solid;
}
.first
{
height: 99.5%;
width: 30%;
border: 1px solid;
margin-left: 47px;
float: left;

}

HTML Code

<html>
<head>
<title>Slide Show</title>
<link rel="stylesheet" type="text/css" href="slideshow.css">
<script type="text/javascript">
var temp="05.jpg";
var x;
function a () {
var img1=document.getElementById('img1');
var img2=document.getElementById('img2');
var img3=document.getElementById('img3');
var temp2;
temp2=img1.src;
img1.src=img2.src;
img2.src=img3.src;
img3.src=temp;
temp=temp2;
 
}
function b () {
// body...
window.clearInterval(x);
}
</script>
</head>
<body style="background:black;">
<div id="container">
<div id="box">
<div class="first" style="margin-left:0px">
<img src="02.jpg" height="100%" width="100%" id="img1" />
</div>

<div class="first">
<img src="01.jpg" height="100%" width="100%" id="img2" />
</div>

<div class="first">
<img src="03.jpg" height="100%" width="100%" id="img3" />
</div>
<form>
<input type="button" value="Start" id="start" onclick="x=window.setInterval('a()',1000);"
style="margin-top:20px; margin-left:16px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#506786; color:white; height:30px; width:55px; font-size:17px;" />
<input type="button" value="Stop" id="Stop" onclick="b()" 
style="margin-top:20px; margin-left:16px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#506786; color:white; height:30px; width:55px; font-size:17px;" />
</form>
</div>
</div>
</body>
</html>

Tuesday, 17 February 2015

Calculator using Javascript.

Output

//Calculator using Javascript.



CSS Code
#container
{
height: 300px;
width: 260px;
margin-left: auto;
margin-right: auto;
border: 7px solid;
border-color: gray;
box-shadow: 2px 2px 15px 1px;
margin-top: 10%;
border-radius: 5px;
}
#screen
{
height: 20%;
width: 99.9%;
margin-left: auto;
margin-right: auto;
background: #3d4543;
}
#input
{
height: 100%;
width: 70%;
float: left;
}
#back
{
height: 100%;
width: 30%;
float: left;
}
#padone
{
height: 20%;
width: 99.9%;
border: 0px solid;
margin-left: auto;
margin-right: auto;
background: #3d4543;
}
#padtwo
{
height: 20%;
width: 99.9%;
border: 0px solid;
margin-left: auto;
margin-right: auto;
background: #3d4543;
}
#padthree
{
height: 20%;
width: 99.9%;
border: 0px solid;
margin-left: auto;
margin-right: auto;
background: #3d4543;
}
#padfour
{
height: 20%;
width: 99.9%;
border: 0px solid;
margin-left: auto;
margin-right: auto;
background: #3d4543;
}
.ninth
{
height: 100%;
width: 25%;
float: left;
}
.eight
{
height: 100%;
width: 25%;
float: left;
}
.seventh
{
height: 100%;
width: 25%;
float: left;
}
.add
{
height: 100%;
width: 25%;
float: left;

}

HTML Code
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "//w3c//DTD XTML 1.0 strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.DTD">
<html>
<head>
<title>Calculator</title>
<link rel="stylesheet" type="text/css" href="calc.css" />
<script type="text/javascript">
var a=0;
function ak(n) 
{
//a=n;
document.getElementById('number').value+=n;
}
function v(val)
{
document.getElementById('number').value=val;
}
function e() 

try 

  v(eval(document.getElementById('number').value)) 

catch(e) 
{
  v('Error') 


</script>
</head>
<body style="background:white;">
<p>Designed by Akshay Sarda. (BCA IV Sem)</p>
<div id="container">
<div id="screen">
<div id="input">
<input type="text" id="number" maxlength="12"
style="height:40px; margin-top:15px; margin-left:10px; box-shadow: 1px 1px 2px 1px; 
border:none; background-color:#bccd95; color:black; font-size:20px; width:167px;" />
</div>
<div id="back">
<input type="button" value=" c " name="button0" id="buttonback" onclick="v(' ')"
style="margin-top:20px; margin-left:16px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:45px; font-size:17px;" />
</div>
</div>

<div id="padone">
<div class="ninth">
<input type="button" value=" 9 " name="button9" id="but9" onclick="ak('9')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; font-size:17px;
border-radius:2px; background:#6f6f6f; color:white; height:30px; width:40px;" />
</div>
<div class="eight">
<input type="button" value=" 8 " name="button8" onclick="ak('8')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="seventh">
<input type="button" value=" 7 " name="button7" onclick="ak('7')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="add">
<input type="button" value=" + " name="button+"  onclick="ak('+')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#ff4561; color:white; height:30px; width:40px; font-size:17px;" />
</div>
</div>

<div id="padtwo">
<div class="ninth">
<input type="button" value=" 6 " name="button6" onclick="ak('6')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="eight">
<input type="button" value=" 5 " name="button5" onclick="ak('5')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="seventh">
<input type="button" value=" 4 " name="button4" onclick="ak('4')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="add">
<input type="button" value=" - " name="button4" onclick="ak('-')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#ff4561; color:white; height:30px; width:40px; font-size:17px;" />
</div>
</div>

<div id="padthree">
<div class="ninth">
<input type="button" value=" 3 " name="button3" onclick="ak('3')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="eight">
<input type="button" value=" 2 " name="button2" onclick="ak('2')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="seventh">
<input type="button" value=" 1 " name="button2" onclick="ak('1')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="add">
<input type="button" value="*" name="button1" onclick="ak('*')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#ff4561; color:white; height:30px; width:40px; font-size:17px;" />
</div>
</div>

<div id="padfour">
<div class="ninth">
<input type="button" value=" 0 " name="button9" onclick="ak('0')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="eight">
<input type="button" value=" . " name="button8" onclick="ak('.')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#6f6f6f; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="seventh">
<input type="button" value=" = " name="button7" onclick="e()" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#FF9933; color:white; height:30px; width:40px; font-size:17px;" />
</div>
<div class="add">
<input type="button" value=" / " name="button6" onclick="ak('/')" 
style="margin-top:15px; margin-left:15px; box-shadow: 1px 1px 2px 0px; border-radius:2px;
background:#ff4561; color:white; height:30px; width:40px; font-size:17px;" />
</div>
</div>
</div>
</body>

</html>

Saturday, 7 February 2015

Program for string comparison [strcmp()] without using string.h header file.

//Program for string comparison [strcmp()] without using string.h header file.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int strcmp(int a[],int b[]);
void main()
{
int str1[40],str2[40];char ch;
int res;
clrscr();
int i=0;
cout<<"Enter two string: ";
while((ch=getchar())!='\n')
{
str1[i]=ch;
i++;
}
str1[i]='\0';
int j=0;
while((ch=getchar())!='\n')
{
str2[j]=ch;
j++;
}
str2[j]='\0';
res=strcmp(str1,str2);
cout<<"Compared String result:"<<res;
getch();
}
int strcmp(int a[],int b[])
{
int i=0,count=0,count1=0;
while(a[i]!='\0')
{
count=count+1;
i++;
}
i=0;
while(b[i]!='\0')
{
count1=count1+1;
i++;
}
if(count==count1)
return 0;
if(count>count1)
return 1;
else
return -1;
}

Program for Encryption and Decryption using structure.

//Program for Encryption and Decryption using structure.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct data
{
char alpha;
char code;
};
void main()
{
data b[]={{'A','à'},{'B','@'},{'C','Z'},{'D','W'},{'E','T'},{'F','Q'},{'G','N'},{'H','K'},{'I','H'},{'J','E'},{'K','B'},{'L','A'},{'M','C'},{'N','F'},{'O','I'},{'P','L'},{'Q','O'},{'R','R'},{'S','U'},{'T','X'},{'U','Y'},{'V','V'},{'W','S'},{'X','P'},{'Y','M'},{'Z','J'}};
char a[26],ch,c[26];
char E,D;
int i,j,k;
clrscr();
cout<<"Enter E for Encryption and D for decryption: ";
cin>>E;
if(E=='E')
{
cout<<"Enter a string: ";

i=0;
while((ch=getchar())!='\n')
{
a[i]=ch;
i++;
}
a[i]='\0';
for(i=0;a[i]!='\0';i++)
{
for(j=0;j<26;j++)
{
if(a[i]==b[j].alpha)
{
c[i]=b[j].code;
break;
}
}
}
c[i]='\0';
cout<<c;
}
else if(E=='D')
{
cout<<"Enter a string: ";
i=0;
while((ch=getchar())!='\n')
{
a[i]=ch;
i++;
}
a[i]='\0';
for(i=0;a[i]!='\0';i++)
{
for(j=0;j<26;j++)
{
if(a[i]==b[j].code)
{
c[i]=b[j].alpha;
break;
}
}

c[i]='\0';
cout<<c;
}
else
{
cout<<"Invalid Input!!"; 
}
getch();
}

Tuesday, 3 February 2015

Operating System

Q. Difference between VMWare and Java Virtual Machine.


VMWare and the rest actually virtualize the hardware of the machine. The operating system running inside of a VMWare container (or Parallels or Windows' virtualization containers or Bochs or ...) have varying degrees of awareness of running within a virtualized container. Within VMWare, the operating system has no idea that it is running within a virtual container. The operating system is not modified at all, although specialized drivers are usually installed (most importantly video) to prevent performance problems. Some other VM's don't do full hardware virtualization and instead require the OS inside the container the make special calls to the container in place of the regular hardware calls.
The JVM is not a virtual machine in that sense at all. No hardware other than the processor is virtualized. The JVM is essentially a virtualized CPU plus the same sort of runtime that is included with a C++ or any other object oriented language, plus garbage collection and other necessities. Additionally, of course, Java class files (and JAR files, etc) are not machine code, but an intermediate byte code. So the JVM has to compile or interpret class files (whether contained in a JAR file or not) at runtime, and has the ability to load and find new code dynamically at runtime.
The JVM is called a virtual machine because the JVM definition defines an abstract machine. This includes registers, stack, etc, and the byte code that Java source is compiled to is practically machine code for this virtual machine. The JVM then interprets or compiles this byte code into native machine instructions.
The difference is essentially that the JVM is a virtualized processor and the other virtual machines are virtualized machines (including video card, network, and other external devices and hardware registers)

Program for Binary and Linear search with function.

//Program for Binary and Linear search with function.

#include<iostream.h>
#include<conio.h>
int linear(int arr[],int value,int low,int high,int found);
int binary(int arr[],int value,int low,int high,int found,int mid);
void main()
{
int arr[10],no,i,j,res=0,res1;
clrscr();
cout<<"Enter 10 values: \n";
for(i=0;i<10;i++)
cin>>arr[i];
cout<<"Enter value to find: ";
cin>>no;
res=linear(arr,no,0,9,0);
res1=binary(arr,no,0,9,0,0);
if(res>0)
cout<<"Value found by linear search\n";
else
cout<<"Value not found by linear search\n";
if(res1>0)
cout<<"Value found by binary search\n";
else
cout<<"Value not found by binary search\n";
getch();
}
int linear(int arr[],int value,int low,int high,int found)
{

while(!found && low<=high)
{
 if(arr[low]==value)
return 1;
 else
low++;
}
return 0;
}

int binary(int arr[],int value,int low,int high,int found,int mid)
{

while(!found && low<=high)
{
mid=(low+high)/2;
if(arr[mid]==value)
return 1;
else
if(arr[mid]<value)
low=mid+1;
else
high=mid-1;
}
return 0;
}

Sunday, 1 February 2015

Program to implement Binary search in C++

//Program to implement Binary search in C++.

#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],i,j,mid,no,found=0;
clrscr();
cout<<"Enter 10 values: \n";
for(i=0;i<10;i++)
cin>>arr[i];
cout<<"Enter value to find: ";
cin>>no;
i=0; j=9;
while(!found && i<=j)
{
mid=(i+j)/2;
if(arr[mid]==no)
found=1;
else
if(arr[mid]<no)
i=mid+1;
else
j=mid-1;
}
if(found)
cout<<"Value found at "<<mid<<" index";
else
cout<<"Value not found";
getch();
}

Program to implement Linear search in C++

//Program to implement Linear search in C++.

#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],i,no,found=0;
clrscr();
cout<<"Enter 10 values \n";
for(i=0;i<10;i++)
cin>>arr[i];
cout<<"Enter values to find: ";
cin>>no;
i=0;
while(!found && i<10)
{
 if(arr[i]==no)
found=1;
 else
i++;
}
if(found)
cout<<"Values found on "<<i<<" index";
else
cout<<"Value not found";
getch();
}

Program to read single digit element in an array and print vertical histogram.

//Program to read single digit element in an array and print vertical histogram.

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,max=0;
clrscr();
cout<<"Enter the no. of element in an array:\n";
cin>>n;
for(i=0;i<n;i++)
{
  cin>>a[i];
  if(a[i]>max)
  max=a[i];
}

for(i=max;i>=0;i--)
  {
     for(j=0;j<n;j++)

{
if(i<a[j])
cout<<"* ";
else
cout<<"  ";
}
cout<<"\n";
   }
getch();
}

Read contacts in iOS using Swift with error handling

Just copy and paste the below code Pre-step before pasting the below code Add below line in AppDelegate.swift file below import statement ...