This blog shows the updates and new information about the things in real life. It also tells the videos in klv productions.
Tuesday, 30 June 2015
Monday, 29 June 2015
Wednesday, 24 June 2015
simple puzzle questions
1.which word does not belongs with others?Give explanation?
a) inch b) ounce c) centimeter d) yard
2.which number replace the questionmark(?)
7 3 6 2
7 2 5 4
1 1 2 4
4 2 1 ?
3.which three numbers have the same answer whether they added or multiplied together?
a) inch b) ounce c) centimeter d) yard
2.which number replace the questionmark(?)
7 3 6 2
7 2 5 4
1 1 2 4
4 2 1 ?
3.which three numbers have the same answer whether they added or multiplied together?
Monday, 22 June 2015
java progrme for quadratic equation to find roots
import java.util.*;
class Abc
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
float a,b,c,d;
float r1,r2;
System.out.println("enter equation numbers");
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
d=(b*b)-(4*a*c);
if(d<0)
{
System.out.println("roots are imaginary");
}
else if(d==0)
{
r1=(float)(-b+Math.sqrt(d))/(2*a);
r2=(float)(-b-Math.sqrt(d))/(2*a);
System.out.println(r1+" "+r2);
}
else
{
r1=r2=-b/(2*a);
System.out.println(r1);
}
}
}
class Abc
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
float a,b,c,d;
float r1,r2;
System.out.println("enter equation numbers");
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
d=(b*b)-(4*a*c);
if(d<0)
{
System.out.println("roots are imaginary");
}
else if(d==0)
{
r1=(float)(-b+Math.sqrt(d))/(2*a);
r2=(float)(-b-Math.sqrt(d))/(2*a);
System.out.println(r1+" "+r2);
}
else
{
r1=r2=-b/(2*a);
System.out.println(r1);
}
}
}
c programe for linear search
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,f=0;// array and variables declaration
printf("enter arry elements");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("enter element to search");
scanf("%d",&n);
for(i=0;i<10;i++)
{
if(a[i]==n)
{
f=1;
break;
}
}
if(f==1)
printf("element found at index %d",i);
else
printf("element not found");
}
#include<conio.h>
void main()
{
int a[10],i,n,f=0;// array and variables declaration
printf("enter arry elements");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("enter element to search");
scanf("%d",&n);
for(i=0;i<10;i++)
{
if(a[i]==n)
{
f=1;
break;
}
}
if(f==1)
printf("element found at index %d",i);
else
printf("element not found");
}
c programe for hashing technique
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int hashtable[40];
int bucket;
int hash(int key)
{
return key%100;
}
int rehash(int key)
{
return (key+1)%100;
}
void insert(void)
{
int data,count=0;
printf("enter data to insert");
scanf("%d",&data);
bucket=hash(data);
if(bucket>=40)
bucket=0;
while(hashtable[bucket]!=0)
{
bucket=rehash(bucket);
count++;
if(count>=40)
{
printf("memory full");
break;
}
}
if(hashtable[bucket]==0)
hashtable[bucket]=data;
printf("data is stored at index%d",bucket);
}
void search(void)
{
int i,isfound=0,key;
printf("enter key to search");
scanf("%d",&key);
for(i=0;i<=40;i++)
{
if(hashtable[i]==key)
{
isfound=1;
break;
}
}
if(isfound==1)
printf("found");
else
printf("not found");
}
void deleteit(void)
{
int key,i,isfound=0;
printf("enter the key to delete");
scanf("%d",&key);
for(i=0;i<40;i++)
{
if(hashtable[i]==key)
{
isfound=1;
break;
}
}
if(isfound==1)
{
hashtable[i]=0;
printf("the key is deleted");
}
else
printf("can't delete");
}
void display()
{
int i;
for(i=0;i<40;i++)
printf("%3d",hashtable[i]);
}
void main()
{
int ch,i;
for(i=0;i<40;i++)
hashtable[i]=0;
while(1)
{
printf("1.insert\n2.search\n3.delete\n4.display\nexit\n");
printf("enter your choice");
scanf("%d",&ch); {
switch(ch)
{
case 1:insert();
break;
case 2:search();
break;
case 3:deleteit();
break;
case 4:display();break;
case 5:exit(0);
default:
printf("entered choice is wrong");
}
}
}
}
#include<conio.h>
#include<stdlib.h>
int hashtable[40];
int bucket;
int hash(int key)
{
return key%100;
}
int rehash(int key)
{
return (key+1)%100;
}
void insert(void)
{
int data,count=0;
printf("enter data to insert");
scanf("%d",&data);
bucket=hash(data);
if(bucket>=40)
bucket=0;
while(hashtable[bucket]!=0)
{
bucket=rehash(bucket);
count++;
if(count>=40)
{
printf("memory full");
break;
}
}
if(hashtable[bucket]==0)
hashtable[bucket]=data;
printf("data is stored at index%d",bucket);
}
void search(void)
{
int i,isfound=0,key;
printf("enter key to search");
scanf("%d",&key);
for(i=0;i<=40;i++)
{
if(hashtable[i]==key)
{
isfound=1;
break;
}
}
if(isfound==1)
printf("found");
else
printf("not found");
}
void deleteit(void)
{
int key,i,isfound=0;
printf("enter the key to delete");
scanf("%d",&key);
for(i=0;i<40;i++)
{
if(hashtable[i]==key)
{
isfound=1;
break;
}
}
if(isfound==1)
{
hashtable[i]=0;
printf("the key is deleted");
}
else
printf("can't delete");
}
void display()
{
int i;
for(i=0;i<40;i++)
printf("%3d",hashtable[i]);
}
void main()
{
int ch,i;
for(i=0;i<40;i++)
hashtable[i]=0;
while(1)
{
printf("1.insert\n2.search\n3.delete\n4.display\nexit\n");
printf("enter your choice");
scanf("%d",&ch); {
switch(ch)
{
case 1:insert();
break;
case 2:search();
break;
case 3:deleteit();
break;
case 4:display();break;
case 5:exit(0);
default:
printf("entered choice is wrong");
}
}
}
}
c progrme for swaping two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter a value and b value");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("after swapping");
printf("%d%d",a,b);
}
#include<conio.h>
void main()
{
int a,b,c;
printf("enter a value and b value");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("after swapping");
printf("%d%d",a,b);
}
Subscribe to:
Posts (Atom)