Monday, August 6, 2012

List of Important My SQL Query used

1.         a)         Create your own database.
 create database Practical;




 
b)         Create table within it with the following fields giving name as Employee
            table.   (Empno,  empname, Job, Salary, Deptno.)

create table Practical.Employee(
Empno int(5),
Empname varchar(50),
Job varchar(50),
Salary float(10,2),
Deptno int(3)
);          

Saturday, March 10, 2012

C Programs Lists With their output

Write a C program to check whether a given number is palindrome or not.

#include 
#include 
void main()
{
 long int n, num, rev = 0, dig;
 printf("\n Enter a number...: ");
scanf("%ld", &num);
 n = num;
while(num>0)
{
dig = num % 10;
 rev = rev * 10 + dig;
 num = num / 10;
 }
 if (n == rev)
 printf("\nGiven number is a palindrome");
 else
 printf("\n Given number not a palindrome");
 getch();
}

Write a program to check whether a given number is armstrong or not.




#include  
#include  
void main()
{
 int a,b,y,m,q;
printf(“Enter any no. \n”);
scanf(“%d”,&a);
 b=a;
y=0;
while(b!=0)
{
 m=b%10;
 q=b/10;
 y=y+(m*m*m);
 b=q;
}
if(y==a)
{
printf(“ The no. is Armstrong\n”); printf("%d\n",a);
}
else
{


printf(“ The no. is not Armstrong\n”); printf("%d\n",a);
}
getch();

}

Write a C program to find prime numbers from 1 to n.

#include
#include
void main()
{
int i,j,n;
clrscr();
printf("Enter the no: ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(j=2;j<=i-1;j++)
{
if(i%j==0)
break;
}
if(j==i)
printf("%d ",j);
}
getch();
}

Write a C program to find the sum of first n natural numbers.

#include  
#include
void main()
{
 int i, n, sum = 0;
clrscr();
printf(“Enter an integer number\n”);
scanf (“%d”, &n);
for (i=1; i <= n; i++)
{
 sum = sum + i;
}
printf (“Sum of first %d natural numbers = %d\n”, n, sum);

getch();
}

Write a program to find the factorial of a number using loop.

#include
#include
void main()
{
int a,b,fact=1;
clrscr();
printf("Enter number to find factorial");
scanf("%d",&b);
for(a=b;a>0;a--)
{
fact=fact*a;
}
printf("%d ",fact);
getch();
}

Write a C program to find the factorial of a number using recursion.

#include
#include
int fact(int);
void main()
{
int num,fact1;
printf("Enter a value of num");
scanf("%d",&num);
fact1=fact(num);
printf("factorial=%d",fact1);
getch();
}
int fact(int n)
{
int f=1;
if(n==0)
{
return 1;
}
else
{
f=n*fact(n-1);
return(f);
}
}

Write a program to find fibonacci series in c using loop.

#include
#include
void fiab(int n)
{
int a=0,b=1,add=0;
printf("%d %d ",a,b);
while(add
{
add=a+b;
a=b;
b=add;
printf("%d ",a);
}
}

void main()
{
int i,j,a,b;
clrscr();
printf("\n Enter number to print fibonacci number:\n");
scanf("%d",&a);
printf("\n Fiabonacci series:\n");
fiab(a);
getch();
}

Write a program to find fibonacci series in c using recursion.

#include
#include
int fiab(int);

void main()
{
int i,n;
clrscr();
printf("How many terms do you wish to find?\n");
scanf("%d",&n);

printf("\nThe Series is : \n");

for(i=1;i<=n;i++)
{
printf(" %d \n",fiab(i));
}

getch();
}

int fiab(int n)
{
if(n==1||n==2){
return 1;}
else{
return(fiab(n-1)+fiab(n-2));}
return 0;
}
 

Write a C program to print the following Pattern

A) 1      
     1 2
     1 2 3
     1 2 3 4 


#include
#include
void main()
{
int i,j;
clrscr();
for(i=0;i<5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}


B)  1
      2 2
      3 3 3
      4 4 4 4 

#include
#include
void main()
{
int i,j;
clrscr();
for(i=0;i<5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ", i);
}
printf("\n");
}
getch();
}





Saturday, February 11, 2012

Valentines Day & Facts about it

Celebrated on February 14, Valentines Day is the festival of love birds across the world, irrespective of the nation, caste, religion or creed. Love birds across the nation await this event desperately throughout the year. However the story of its origin is still under blurred sacks. There are different ideas to the way Valentines Day celebration began. Some trace it to Lupercalia, an ancient Roman festival while other experts associate the event with two saints named valentine of the early Christian church. One of them would secretly conduct marriage of couples by disobeying the rule of Roman Emperor, Claudius; while other was a lover of children but, was imprisoned when he would not honor other gods. The children missed him and wrote messages of affection to him through the bars of the cell. This can be considered as the beginning of exchanging messages. Still others link it with an old English belief that love birds choose their mates on February 14. Valentine's Day probably came from a combination of all the above sources, along the belief that spring is a time for lovers. Read on to find out all interesting facts about this festival.

Fun Facts On Valentine’s Day
  • The modern day celebration of Valentines Day is believed to begin in France and England.
  • Cupid (symbol for Roman God of love), doves, love birds, roses, hearts and arrows are all symbols of the Valentine’s Day celebration.
  • Pope Gelasius declared February 14 St. Valentine's Day around 498 A.D.
  • In Great Britain, Valentine's Day began to be celebrated around seventeenth century. By the middle of the eighteenth century, it was common for friends and lovers to exchange small tokens of affection or handwritten notes.
  • In Medieval times, girls ate bizarre foods on St Valentine's Day to dream of their future spouse. 
  • There was a belief in the Middle Ages that the first unmarried person (of the opposite sex) you met on the morning of St. Valentine's Day would become your spouse.
  • The first Valentine gift was sent by Duke of Orleans to his wife, after he was captured in 1415.
  • 73% of Valentine Day flowers are bought by men, whereas women buy only 23% of Valentine flowers.
  • Around 3% of pet owners prefer to give Valentine gifts to their pets, as they are more grateful than humans.
  • In oden times, some people believed that if a woman saw a robin flying overhead on Valentine's Day, it meant she would marry a sailor. If she saw a sparrow, she would marry a poor man and be very happy. If she saw a goldfinch, she would marry a millionaire.
  • The heart is the most common symbol of romantic love. Ancient cultures believed the human soul lived in the heart and its red color is though to be the most romantic.
  • The red rose was the favorite flower of Venus, the Roman goddess of love. Since red stands for strong feelings, red rose is a flower of love.
  • The first Valentine's Day box of chocolates was introduced by Richard Cadbury in 1868.
  • In Wales, wooden love spoons were carved and given as gifts on Valentine’s Day. Hearts, keys and keyholes were favorite Valentine decorations on the wooden spoons that meant, "You unlock my heart!"

14 Miserable Facts About St Valentine’s Day 

1. In the two week period leading up to Valentine’s Day, American sales of gold jewelry lead to 34 million metric tons of waste.
2. The vast majority of roses sold for Valentine’s Day in the U.S. are imported from South America, wasting fossil fuels.
3. Valentine’s Day traces its roots to an ancient pagan holiday called Lupercalia, in which men stripped naked, grabbed whips, and spanked young women in hopes of increasing their fertility.
4. The Christian martyr St. Valentine was beheaded on February 14 for performing marriages in secret.
5. Research suggests that 75 percent of suicide attempts are attributable to relationship problems.
6. 46 percent of Americans will exchange Valentine’s Day candy.
7. 67 percent of Americans are overweight or obese.
8. The first Valentine’s Day card was sent by Charles, Duke of Orleans, to his wife while he was imprisoned in the Tower of London. He remained a prisoner of war for the next twenty-four years.
9. A recent poll found that one in ten young adults admitted to feeling lonely, insecure, depressed, or unwanted on Valentine’s Day. And that’s just the ones that admitted it.
10. Forty percent of people have negative feelings towards Valentine’s Day.
11. The famous St. Valentine’s Day Massacre, in which seven Chicago gangsters were gunned down on February 14, 1929, was one of the bloodiest in mob history (pictured above).
12. 64 percent of American men do not make Valentine’s Day plans in advance.
13. Candy hearts taste like crap.
14. Even if you’re really, really in love right now, you’re still going to die eventually.
15. In reality, there were actually 3 St. Valentine’s. One was a priest, one a bishop and one little is known about except he was a martyr. The stories of the priest’s and bishop’s martyrdom are so closely related it is difficult to tell which St. Valentine the Holiday is named after.
16. According to legend it was St. Valentine himself who sent the first valentine in the form of a letter to his jailer’s blind daughter with whom he had fallen in love. Just before he was put to death at the hands of King Claudius II for marrying the kings soldiers without the king’s permission he penned a note to his love and signed it: From your Valentine.
17. It is believed that a mount Holyoke college student by the name of Ester Howland created the first lace valentine in the United States from lace, ribbon and colorful pictures. She has become known as the Mother of the Valentine.
18. Teachers receive more valentine cards than anyone else, even children.
19. More than 650 million valentine cards are exchanged by children from ages 6-10 each year. Most of these cards are bought in the last 6 days leading up to Valentine’s day.
20. Each year the city of Verona Italy receives more than 1000 valentine’s addressed to Shakespeare’s Juliet. It really is amazing how much affection a dead fictional character can attract.
21. It was once believed that if a woman saw a flying robin on Valentine’s day she would end up getting married to a sailor. If a sparrow was the bird she saw she would end up marrying a man that was poor and live a happy life, if she saw a goldfinch then she was to marry a man that was a millionaire. One can only wonder who she would marry if she saw a crow.
22. In 1929 at the height of prohibition Al Capone ordered the killing of members of a rival gang run by Bugs Moran in Chicago on Valentines Day. Authorities were unable to find any real evidence to tie Capone to the crime and he was never arrested or tried for the murder of these seven men. Instead he served his time for tax evasion.
23. More than 9 million pet owners buy gifts for their pets for Valentine’s day. Now that is what can be called real puppy love.
24. It is estimated that 15% of the women in the United States who receive flowers for Valentine’s day send them to themselves. There are no figures that tell how many of these women are married, single or in a relationship.