-->

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();
}

WAP to display the name of day on the basis of entered number 1 to 7 using switch. For example, 1 for Sunday.

//WAP to display the name of day on the basis of entered number 1 to 7 using switch. For example, 1 //for  Sunday.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int number,output;
printf("'we have following menu\n");
printf( "1.for Sunday\n");
printf("2. for Monday\n");
printf("3 for Tuesday\n");
printf("4 for Wednesday\n");
printf("5 for Thrusday\n");
printf("6 for Friday\n");
printf("7 for Saturday\n");
printf("enter your choice 1 or 2 or 3 or 4 or 5 or 6 or 7 or any other number to exit\n");
scanf("%d",&choice);
 switch(choice)
          {
                  case 1:
                            printf("It's Sunday\n");
                            
                break;
               case 2:
                            printf("It's Monday\n");
                 break;

               case 3:
                           printf("IT's Tuesday\n");                            
                 break;
             case 4:
                       printf("It's Wednesday\n");
            break;
          case 5:
                      printf("It's Thrusday\n");
          break;
           case 6:
                     printf("It's Friday\n");
            break;  
            case 7:
                        printf("It's Saturday\n");
           break; 
           default:
                            printf("sorry, not a valid input\n");
                            printf("thank u, terminating....\n");
          }
getch();
}

WAP to find sum,difference, and product of two numbers using switch.

//WAP to find sum,difference, and product of two numbers using switch.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int a,b,output;
printf("please enter your two numbers for a and b for operation\n");
scanf("%d%d",&a,&b);
printf("'now,we have following menu\n");
printf( "1.to get sum\n");
printf("2. to get difference\n");
printf("3 to get product\n");
printf(" any other number to exit");
printf("enter your choice 1 or 2 or 3 or any other number\n");
scanf("%d",&choice);
 switch(choice)
          {
                  case 1:
                            printf("we are going to get sum\n");
                           printf("the sum=%d",a+b);
                 break;
               case 2:
                            printf("we are going to get difference \n");
                           printf("the difference=%d",a-b);
                 break;

               case 3:
                            printf("we are going to get product,\n");
                           printf("the product=%d",a*b);
                 break;
             
              default:
                            printf("sorry, not a valid input\n");
                            printf("thank u, terminating....\n");
          }
getch();
}