-->

WAP to count number of vowels and consonants given in a text.

//WAP to count number of vowels and consonants given in a text.
#include<stdio.h>
include<conio.h>
#include<ctype.h>void main()
{                                                           
char name[30];                                                    
int i,vowel=0,cnst=0;
printf("enter string\n");
gets(name);

for(i=0;name[i]!='\0';i++)
{
if(name[i]==toupper(a)  || name[i]==toupper(e) || name[i]==toupper(i) || name[i]==toupper(o) || name[i]==toupper(u))
{
  vowel++;
}
else
{
  cnst++;
}
}
printf("total vowel present=%d\n",vowel);
printf("total consonant present=%d\n",cnst);
getch();
}
        

WAP to count total number of particular character present in a string.

//WAP to count total number of particular character present in a string.
#include<stdio.h>
include<conio.h>
void main()
{                                                           
char name[30], c;                                                    
int i,count=0;
printf("enter string\n");
gets(name);
printf("enter a character \n");
c=getchar();
for(i=0;name[i]!='\0';i++)
{
if(name[i]==c)
{
  count++;
}
}
printf("total character present=%d\n",count);
getch();
}
        

WAP to know a number /string is Palindrome or not.

// WAP to know a number /string is Palindrome or not.
#include<stdio.h>
include<conio.h>
void main()
{                                                           
char name[30];                                                    
char temp[30];
printf("enter string\n");
gets(name);
strcpy(temp,name);
if((strcmp(strrev(name),temp))==0)
{
  print("it is palindrome\n");
}
else
{
printf("it is not\n");
}
getch();
}
        

WAP to store book's name,price and author's name in a file named 'book.dat' and then read and display on monitor.

//WAP to store book's name,price and author's name in a file named 'book.dat' and then read and display on //monitor.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                                    //  pointer for file declaration
char book_name[30],,author[100],choice;                                                    //identifier declaration
int book_price;                                             //       "             "
k=fopen("book.dat","w");
do
{
printf("enter book's name\n");                                       // getting inuts
gets(book_name);
printf("enter book's price\n");
scanf("%d",&book_price);
printf("enter author\n");
scanf("%s",author);

fprintf(k,"%s %d %s",book_name,book_price,author);   //writing data to data file
printf("want to continue y/n\n");
choice=getche();                                                        //getting a character from user  
}while(choice!='n');                                                      // validating the input
printf("writing process completed successfully\n");
fclose(k);                                                                                   //closing data file
printf("now reading the records\n");
k=fopen("book.dat","r");
while((fscanf(k,"%s %d %s",book_name,&book_price,author)!=EOF))//reading data from data file
{
printf("book name=%s , price=%d", and author name=%s",book_name,book_price,author_name); //displaying data
}
fclose(k);
getch();
}

WAp to enter student's name,his/her address and their roll number using struct. Then display them

//WAp to enter student's name,his/her address and their roll number using struct. Then display them
#include<stdio.h>
#include<conio.h>
struct detail
{
int roll;
char name[100];
char address[100];
}var[100];

void main()
{
int i,j,n;
printf("enter total number of records (less or than '100')\n");
scanf("%d",&n);
printf("now enter records of students\n");
for(i=0;i<n;i++)
{
printf("enter student's roll no.\n");
scanf("%d",&var[i].roll);
printf("enter student's name\n");
scanf("%s",var[i].name);
printf("enter student's address\n");
scanf("%s",var[i].address);
}
printf("entered records are=\n");
  for(i=0;i<n;i++)
{
printf("student's roll=%d, name=%s,student's address=%s \n",var[i].roll,var[i].name,var[i].address);
}
getch();
}

WAP to get factorial value of a number.

//WAP to get factorial value of a number.
#include<stdio.h>
include<conio.h>
void main()
{
   int number,fact=1,i;
   printf("enter any positive number\n");
  scanf("%d",&number); 
 for(i=1;i<=number;i++)
    {
     fact=fact*i;
   }
 printf("the factorial value for entered number=%d is =%d\n",number,fact);
getch();
}
-----------------------------------------------------------------------------------
Or
-------------------------------------------------------------------------------
//program to get factorial value of a positive number
#include<stdio.h>
include<conio.h>
void main()
{
   int number,fact=1,i;
   printf("enter any positive number\n");
  scanf("%d",&number);
if(number>0)

 for(i=1;i<=number;i++)
    {
     fact=fact*i;
   }
}
else
{
printf("the number is not +ve\n");
}
 printf("the factorial value for entered number=%d is =%d\n",number,fact);
getch();
}

WAP to input salary of 'n'number of employees then count total number of employees getting salary in different range

//WAP to input salary of 'n'number of employees then count total number of employees getting salary in different //range
/*
-> less than 5000
 > >=5000 and < 10000
 >  >10000
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,count=0,count1=0,count2=0;
in salary[1000];
printf("enter total number of employees below 1000\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter salary\n");
scanf("%d",&salary[i]);
  if(salary[i]<5000)
   {
     count++;
    }
   else if(salary[i]>=5000 && salary[i]<=10000)
              {
                count1++;
              }
   else
     {
          count2++;
      }
}
printf("total emplyoees getting less than 5000=%d\n",count);
printf("total employees getting more or equals to 5000= and less than 10000=%d\n",count1);
printf("total emplyoees getting more than 10000=%d\n",count2);
getch();
}