Thursday, July 26, 2012

C Program to Calculate Square Root Of a Number

#include<stdio.h>
#include<conio.h>
float sqroot(float );
void main()
{
    float n,a;
    scanf("%f",&n)
    a=sqroot(n);
    getch();
}
    float sqroot(float m)
{
      float i=0;
    float x1,x2;
    while( (i*i) <= m )
             i+=0.1;
    x1=i;
    for(int j=0;j<10;j++)
    {
          x2=m;
        x2/=x1;
        x2+=x1;
        x2/=2;
        x1=x2;
    }
    return x2;
}

Wednesday, July 25, 2012

C Password Program


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i;
int d;
         d=42;  // ascii OF *
char a[5],b[5];
printf(" Enter the 5 letter PASSWORD\n ");
printf(" pASSWORD ::: ");
for(i=0;i<5;i++)
  { a[i]=getch();
b[i]=d;
printf("%c",b[i]);
  }


  if(a[0]=='L' && a[1]=='O' && a[2]=='V' && a[3]=='E' && a[4]=='U' )
printf(" \n <<<<<<<...........Welcome...........>>>>>>>> ");
else
printf(" \n !.........Sorry!Incorrect password.........! ");




}






:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


for login......
Password : LOVEU