GoogelAddUnit1

Thursday, 10 March 2011

C Program to counting of no of vowels ,words whites, digits, others.

/*   counting of no of vowels ,words whites, digits, others */ 
         
#include<stdio.h>
#include<conio.h>
main()
{
  char a[80],c;
  int i=0,ove=0,con=0,dig=0,whit=0,words=0,othe=0;
  printf("\n enter the string ");
  scanf("%s",a);
  while((c==tolower(a[i++])!='\0'))
  {
    if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u'))
      ove++;
    else if((c>='a')&&(c<='z'))
      con++;
    else if((c>='0')&&(c<='9'))
     dig++;
     else if(c=='\0')
      {
       whit++;
       words++;
       while((a[i++]==' ')||(a[i++]=='\t'))
       {
    whit++;
    i++;
       }
      }
    else
      othe++;
  }
  whit++;
  printf("\n ove=%d\ncon=%d\ndig=%d\nwhit=%d\nwords=%d\nothe=%d\n",ove,con,dig,whit,words,othe);
  getch();
}

C Program to Calculate Employee Gross and Net Salary.

#include<stdio.h>                           
#include<conio.h>
main()
{
int eno,bs;
float hra=0,da=0,gs=0,pf=0,it=0,ns=0;
char name[20];
clrscr();
printf("Enter the eno,name,bs");
scanf("%d%s%d",&eno,name,&bs);

        if(bs<=5000)
        {
        hra=(bs*10)/100;
        da=(bs*15)/100;
        gs=bs+hra+da;
        pf=(gs*3)/100;
        it=(gs*1)/100;
        ns=gs-(pf+it);
        }
        if((bs>5000)&&(bs<=10000))
        {
        hra=(bs*30)/100;
        da=(bs*20)/100;
        gs=bs+hra+da;
        pf=(gs*5)/100;
        it=(gs*2)/100;
        ns=gs-(pf+it);
        }
        printf("\n Name is =%s", name);
        printf("\n Employee No is =%d", eno);
        printf("\n Basic Salary is =%d", bs);
        printf("\n Gross Salary is =%f", gs);
        printf("\n PF is =%f", pf);
        printf("\n IT is =%f", it);
        printf("\n NET Salary is =%f", ns);
        getch();
        }

C Program to find the Standard Deviation.

/*STANDERD DEVIATION*/     
                 
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,x[100],sum,i;
float mean,vsum,ksum,sd;
clrscr();
printf("Enter the n value\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&x[i]);
}
for(i=0;i<n;i++)
sum=sum+x[i];
mean=sum/n;
for(i=0;i<n;i++)
vsum=vsum+((x[i]-mean)*(x[i]-mean));
ksum=vsum/n;
sd=sqrt(ksum);
printf("%f",sd);
getch();
}

C Program to Tower of Honai Problem.

/* tour of hanai */
#include<stdio.h>                           
#include<conio.h>
void main()
{
int n,
char sn='l';
char in='c';
char dn='r';
honai();
printf("Enter number of disks");
scanf("%d",&n);
printf("The tour of honai problem with%d disks",n);
honai(n,sn,in,dn);
printf("\n");
}
honai(int n,int sn,int in,int dn)
{
int n;
char sndl,indl,dndl;
{
if(n!=0)
honai(n-1,sndl,dndl,indl);
printf("move disk %d from %c to %c",n,sndl,dndl);
honai(n-1,indl,sndl,dndl);
}
}