Slip 1.AProgram  to accept  a four digit number from user  and count  zero , odd     
            
           
          
         
   
       
              
    
   
   
                                                            
                        
                            
             
            
  
and even digits  of the entered number.
#include  <stdio.h>
#include<conio.h>
void  main()
{
  int rem,num,evencnt=0,oddcnt=0,zerocnt=0;
  printf("Enter an integer: ");
  scanf("%d", &num);
while(num  >0)
            {
                        rem= num % 10;
                        num=num /10;
                        if((rem!= 0) &&  (rem % 2 == 0))
                        {
                                    evencnt++;
                        }
                        else if(rem== 0)
                        {
                                    zerocnt++;
                        }
                        else
                        {
                                    oddcnt++;
                        }
}
getch();
  printf("Number of even:  %d",evencnt);
printf("\n  number of add :%d",oddcnt);
printf("\n  number of  zero:%d",zerocnt);
getch();
}
/* putput
Enter an  integer: 7654
Number of even:  2
 number of add :2
 number of   zero:0 */
1B.program  name:- menu driven program
             _ Add book information
            _ Display book information
#include<stdio.h>
#include<conio.h>
#include<string.h>
 void main()
 {
  struct book
  {
  int bno;
  char bname[20];
  char author[20];
  }b[5];
  int i,n,ch;
  char name[20],c;
  clrscr();
   while(1)
            {
            printf("\n menues");
            printf("\n 1.Add book  information");
            printf("\n 2.display book  information");
            printf("\n 3. exit from  program");
            printf("\n Enter your  choice=");
            scanf("%d",&ch);
            switch(ch)
                        {
                                    case 1:  printf("\n How many info.you want to add=");
                                    scanf("\n  %d",&n);
                                    for(i=0;i<n;i++)
                                    {
                                    printf("Enter  the book.no=");
                                    scanf("\n  %d",&b[i].bno);
                                    printf("Enter  the book name=");
                                    scanf("\n  %s",&b[i].bname);
                                    printf("Enter  the author name=");
                                    scanf("\n  %s",&b[i].author);
                                    }
                           break;
            case 2:
                           printf("\n  BNO\t BOOKNAME\tBOOKAUTHOR");
                                    for(i=0;i<n;i++)
                                    printf("\n  %d\t%s\t%s",b[i].bno,b[i].bname,b[i].author);
                                    break;
             case 3: exit(0);
   default :printf("\nEnter you correct  choice");
            }
            }
            getch();
  }
/* output 
 menues
 1.Add book information
 2.display book information
 3. exit from program
 Enter your choice=1
 How many info.you want to add=3
Enter the  book.no=1
Enter the book  name=cprogramming
Enter the author  name=kanetkar
Enter the  book.no=2
Enter the book  name=inventory
Enter the author  name=sharma
Enter the  book.no=3
Enter the book  name=multimedia
Enter the author  name=shirshetti
 menues
 1.Add book information
 2.display book information
 3. exit from program
 Enter your choice=2
  BNO     BOOKNAME       BOOKAUTHOR
 1       cprogramming    kanetkar
 2       inventory       sharma
 3       multimedia      shirshetti
 menues
 1.Add book information
 2.display book information
 3. exit from program
 Enter your choice=
 Slip 2A.Write  a C program to generate the following pattern for n lines:          
                        Aa
                        Aa       Bb
                        Aa       Bb       Cc
                        Aa       Bb       Cc       Dd       */
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
char c,ch;
clrscr();
for(i=1;i<=4;i++)
{
c='A';
ch='a';
for(j=1;j<=i;j++)
{
printf(" %c%c",c,ch);
c=c+1;
ch=ch+1;
}
printf("\n");
}
getch();
}
/*out put:-
 Aa
 Aa Bb                                                                           
 Aa Bb Cc                                                                        
 Aa Bb Cc Dd  */
2 B.program  name:=factorial of given number by using recursion
#include<stdio.h>
#include<conio.h>
int  recfact(int n);
void  main()
{
  int n,ans;
  printf("\n enter the number");
  scanf("\n %d",&n);
  ans= recfact(n);
   printf("\n factorial is %d",ans);
   getch();
   }
   int recfact(int n1)
   {
             int rem,fact=0;
             if(n1==1)
                {
                          return 1;
                          }
                        else
                        {
                          fact=n1*recfact(n1-1);
                          }
                          return fact;
                          }
/* output
 enter the number=5
 factorial is 120 */
Slip 3A. Program  to check whether a given number is Armstrong or not
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int num,sum=0,rem,temp;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 temp=num;
 while(num>0)
  {
  rem=num%10;
  sum=sum+(rem*rem*rem);
  num=num/10;
  }
 if(temp==sum)
  {
  printf("\n number is armstrong");
  }
  else
  {
  printf("\n number is not  armstrong");
  }
 getch();
 }
/*output
enter the value  of num153
 number is armstrong*/
3 B.Program to  do the following 
a)         Create a text file ‘input.txt’
b)         Print the contents of file in reverse  order
#include<stdio.h>
#include<conio.h>
void  main()
{
 FILE *fp;
 char ch,s[100];
 int i=0;
 clrscr();
 printf("Enter the content of  file\n");
 fp=fopen("E:\input.txt","w");
 while((ch=getchar())!=EOF)
 {
  fputc(ch,fp);
  }
  fclose(fp);
   fp=fopen("E:\input.txt","r");
  while((s[i]=fgetc(fp))!=EOF)
  {
   i++;
   }
   while(i>=0)
   {
    printf("%c",s[i]);
    i--;
   }
   fclose(fp);
  getch();
  }
/* output
Enter the  content of file
india is my  country
all indians^Z
 snaidni  lla
yrtnuoc ym si  aidni
*/
Slip 4A.program  name:program to calculate the sum of digits of a given number
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int num,rem,sum=0;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 while(num>0)
  {
  rem=num%10;
  sum=sum+rem;
  num=num/10;
  }
  printf("\n %d",sum);
  getch();
 }
/* output
 enter the value of num678
 21 */
4B.program to  accept customer details such as: Account_no, Name, 
Balance in  account,. Assume Maximum 10 customers in the bank. Write a function to print  the account no and name of each customer with balance below Rs.100. (using  structure) 
#include<stdio.h>
#include<conio.h>
struct  customer
{
int  accno;
char  name[20];
int  balance;
}cust[5];
void  display(struct customer[5]);
void  main()
{
struct  customer c[5];
clrscr();
display(c);
getch();
}
void  display(struct customer cust[5])
{
int  i;
               printf("\n enter customer information");
   for(i=0;i<5;i++)
   {
            printf("\n enter the account  no:");
            scanf("%d",&cust[i].accno);
            printf("\n enter the custmer  name:");
            scanf("%s",&cust[i].name);
            printf("\n enter the  balance:");
            scanf("%d",&cust[i].balance);
            }
printf("\n  the customer details are");
printf("\n  Account no\tname");
            for(i=0;i<5;i++)
            {
if(cust[i].balance<100)
{
printf("\n\t%d",cust[i].accno);
printf("\t%s",cust[i].name);
}
}
}
/* output 
 enter customer information
 enter the account no:101
 enter the custmer name:mane
 enter the balance:23456
 enter the account no:102
enter the  custmer name:sane
 enter the balance:78
 enter the account no:103
 enter the custmer name:sharma
 enter the balance:5098
 enter the account no:104
 enter the custmer name:raj
 enter the balance:34
 enter the account no:105
 enter the custmer name:rahul
 enter the balance:4567
 the customer details are
 Account no      name
        102      sane
        104      raj         */
Slip 5A.Program  to accept a string from user and generate following pattern
            (e.g.  input is string “abcd”).                                                                                                                                                                                                                         
a
a b
a b c
a b c d
a b c
a b
a 
#include<stdio.h>
#include<conio.h>
#include<string.h>
void  main()
{
char  s[10];
int  l=0,i,j;
clrscr();
printf("Enter  the string=");
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",s[j]);
}
printf("\n");
}
for(i=l-1;i>0;i--)
{
for(j=0;j<i;j++)
{
printf("%c",s[j]);
}
printf("\n");
}
getch();
}
/* output
Enter the  string=abcd
a
ab
abc
abcd
abc
ab
a
*/
5B.Program name  write a c program to copy the content of file into another file
#include<stdio.h>
#include<conio.h>
void  main()
{
FILE  *fs,*ft;
char  ch;
clrscr();
fs=fopen("a.txt","r");
if(fs==NULL)
{
printf("\n  unable to open file");
}
ft=fopen("b.txt","w");
if(ft==NULL)
{
printf("cannot  open target file");
}
while((ch=fgetc(fs))!=EOF)
{
fputc(ch,ft);
}
fclose(fs);
fclose(ft);
getch();
}
Slip 6A.Write a  ‘C’ program to accept a string from user and delete all the vowels from that  string & display the result
#include<stdio.h>
#include<conio.h>
void  main()
{
int  i=0,flag=0;
char  s[50];
clrscr();
printf("\n  enter the string:-");
gets(s);
while(s[i]!=NULL)
{
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'  || s[i]=='E' || s[i]=='I'|| s[i]=='O' || s[i]=='U')
{
continue;
}
else
{
printf("%c",s[i]);
}
i++;
}
getch();
}
6B.program to  display transpose of matrix using user defined function
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void  main()
{
int  a[3][3],sum=0;
int  i,j,n;
clrscr();
printf("\n  enter the value of row and col");
scanf("\n  %d",&n);
a[i][j]=(int)calloc(n,sizeof(int));
printf("\n  enter the array element-");
for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
  {
            sum=sum+a[i][j];
            }
            }
            printf("\n the sum of matrix  elements is %d",sum);
getch();
}
/* output
 enter the value of row and col3
 enter the array element-
1 2 3
4 5 6
7 8 9
 the sum of matrix elements is 45*/
Slip 7A.Write a  C program to generate the following pattern for n lines:         
1          2          3          4
5          6          7
8          9          
10      */
#include<stdio.h>
int  main()
{
  int i,j,k;
  k=1;
  clrscr();
  for(i=1;i<=5;i++)
  {
            for(j=4;j>=i;j--)
            {
        printf("%d",k++);
    }
    printf("\n");
  }
  getch();
}
/*output
  1   2   3   4
  5   6   7
  8   9
 10  */
7B.Write a C  program to perform the following operations on string using user defined    function
a.         Calculate length of string.
b.         Copy one  string into another.
 # include<stdio.h>
  void main()
       {
           int ch;
           void len();
           void copy();
                           clrscr();
                           while(1)
                           {
                           printf("\n- : User Defined String  Functions : -");
           printf("\n1 Find String Length  ");
           printf("\n 2String Copy  ");
           printf("\n3 Exit");
           printf("\n Enter Your Choice:  ");
                           scanf("%d",&ch);
                           switch(ch)
                           {
               case 1:
                   len();
                   break;
               case 2:
                   copy();
                   break;
               case 3:
                   exit();
  }
                           getch();
                           }
       }
       void len()
       {
           char str[50];
           int l;
           printf("\nEnter String :  ");
           scanf("%s",str);
           l=strlen(str);
           printf("\nLength = %d",l);
       }
       void copy()
       {
           char str1[50],str2[50];
        int i,j,n,k;
        clrscr();
        printf("\n Please Give The STRING1 :  ");
        scanf("%s",str1);
        printf("\n Please Give The  STRING2: ");
        scanf("%s",str2);
        strcpy(str1,str2);
        printf("\n AFTER COPYING STRING2  INTO STRING1 IS  %s .",str1);
                }
/* output
   User Defined String Functions : -
1 Find String  Length
 2String Copy
3 Exit
 Enter Your Choice       : 2
 Please Give The STRING1 : asha
Please Give The  STRING2: anita
 AFTER COPYING STRING2 INTO STRING1 IS  anita .
- : User Defined  String Functions : -
1 Find String  Length
 2String Copy
3 Exit
 Enter Your Choice       : 1
Enter String :  india
Length = 5 */
Slip 8A.Write a C program to generate following pattern for n  lines:   
      *                                            
                                    *          *                                                          
                              *           *           *                                                   
                         *           *            *          * 
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,row,col;
clrscr();
printf("input the number of rows=");
scanf("%d",&row);
printf("input the number of column=");
scanf("%d",&col);
for(i=0;i<row;i=i+1,col=col-1)
{
for(k=0;k<col;k=k+1)
printf(" ");
for(j=0;j<=i;j=j+1)
{
printf("* ");
}
printf("\n");
}
getch();
return(0);
}
/*out put:-
input the number of  rows=4
input the number of  column=8                                                     
         *                                                                        
       *  *                                                                       
      *  *  *                                                                      
     *  *   *  *                   */
8 B.Write a ‘C’ Program to calculate sum of elements of a mXn  matrix 
#include<stdio.h>
#include<conio.h>
void  main()
{
int  a[10][10],i,j,m,n,sum=0;
clrscr();
printf("\nEnter  the 3*3 matrix=");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum=sum+a[i][j];
}
}
printf("\nsum  of elements of matrix is=%d",sum);
getch();
}
/* Output
Enter the 3*3  matrix=
1 2 3
4 5 6
7 8 9
sum of elements  of matrix is=45 */
Slip 9A.Write a C program to calculate sum of Fibonacci series up  to a given number.         
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int n,a=0,b=1,i,c;
 clrscr();
 printf("\n enter two many term u  want");
 scanf("\n %d",&n);
 printf("\n %d",a);
 printf("\n %d",b);
 for(i=1;i<=n;i++)
  {
  c=a+b;
  printf("\n %d",c);
  a=b;
  b=c;
  }
  getch();
 }
/* output
 enter two many term u want5
 0
 1
 1
 2
 3
 5
 8 */
9 B. Write a ‘C’ Program to accept ‘n’ numbers from user, store  these numbers into an 
array  and count the number of occurrence of each number.
#include<stdio.h>
#include<conio.h>
void  main()
{
int  n,i,j,cnt,a[10],temp,no;
clrscr();
printf("\nenter  the limit = ");
scanf("%d",&n);
printf("\n  Enter the %d number",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n;i=j)
{
no=a[i];
cnt=1;
for(j=i+1;j<n;j++)
{
if(a[j]!=no)
break;
else
cnt++;
}
printf("\n%d  no occurs %d times\n ",no,cnt);
}
getch();
}
/* output
enter the limit  = 5
 Enter the 5 number
11
56
89
22
11
11 no occurs 2  times
22 no occurs 1  times
56 no occurs 1  times
89 no occurs 1  times */
Slip 10A. Write  a C  program to calculate x(y+z) by using  user defined function
#include<stdio.h>
void  power(int x,int y, int z);
void  main()
{
 int x,y,z;
 printf("Enter value of x: ");
 scanf("%d",&x);
 printf("Enter value of y: ");
 scanf("%d",&y);
 printf("Enter value of z: ");
 scanf("%d",&z);
 power(x,y,z);
}
void  power(int x,int y, int z)
{
 int ans = 1, i;
 for(i = 1; i <= (y+z); i++)
  ans *= x;
 printf("%d ^ (%d+%d) =  %d",x,y,z,ans);
}
/* output
Enter value of  x: 1
Enter value of  y: 2
Enter value of  z: 3
1 ^ (2+3) = 1 */
10B. program  name:- write a menu driven prodram in 'c' which performs the following  ,operations on string . write separate function for each option,
               -cheak if one string is  substring of another string ,
               -count number of occurrences of  acharacter in the string,
               -Exit.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void  main()
{
int  ch;
char  str1[30],str2[30],occ;
int  i=0,cnt=0;
clrscr();
while(1)
{
printf("\n  menues");
printf("\n1.  check if one string is substring of another string");
printf("\n2.  count number of occurrences of characters in the string");
printf("\n3.exit");
printf("\nEnter  Your choice: ");
scanf("%d",&ch);
switch(ch)
{
case  1:printf("\n enter the first string");
                scanf("%s",str1);
                printf("\n enter the second string");
                scanf("%s",str2);
                if(strstr(str1,str2)==NULL)
                        {
                         printf("\n  second string is not substring of first  string");
                         }
                         else
                         {
                                    printf("\n  second string is  substring of first string");
                          }
                break;
case  2:
                        printf("\n enter  the string");
                        scanf("%s",&str1);
                printf("\n enter the  character  to find occurences");
                scanf("%s",&occ);
                i=0,cnt=0;
                while(str1[i]!='\0')
                        {
                         if(str1[i]==occ)
                        {
                         cnt++;
                         }
                         i++;
                        }
                printf("\n the number of occurencs is %d",cnt);
                break;
case  3:exit(0);
               }
               }
                getch();
               }
   /*output
 menues
1. check if one  string is substring of another string
2. count number  of occurrences of characters in the string
3.exit
Enter Your  choice: 1
 enter the first stringindia
enter the second  stringind
  second string is  substring of first string
 menues
1. check if one  string is substring of another string
2. count number  of occurrences of characters in the string
3.exit
Enter Your  choice: 2
 enter the stringmaharashtra
enter the  character to find occurencesa
 the number of occurencs is 4
 menues
1. check if one  string is substring of another string
2. count number  of occurrences of characters in the string
3.exit
Enter Your  choice:
Slip 11A.  program to accept character & display its ASCII value and its next  &     
                        previous  character
#include<stdio.h>
#include<conio.h>
void  main()
 {
 char ch;
 clrscr();
 printf("\n enter the value ch");
 scanf("\n %c",&ch);
 printf("\n the ascii value of character  is %d",ch);
 printf("\n the next ascii character is  %c",ch+1);
 printf("\n the privious ascii character  is %c",ch-1);
 getch();
 }
/*output
 enter the value ch   c
 the ascii value of character is 99
 the next ascii character is d
 the privious ascii character is b*/
11B. Write a ‘C’ Program to accept ‘n’  numbers and store all prime numbers in an 
     array and display this array
 #include<stdio.h>
#include<conio.h>
void  main()
{
int  a[10],n,i,j,sum=0,prime[10],t=0;
clrscr();
printf("Enter  the value of n=");
scanf("%d",&n);
printf("Enter  the array=\n");
for(i=0;i<n;i++)
{
printf("Enter  number=%d",i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
sum=0;
for(j=2;j<a[i];j++)
{
if(a[i]%j==0)
{
sum=1;
break;
}
}
if(sum==0)
{
prime[t]=a[i];
t++;
}
}
printf("prime  number is=");
for(i=0;i<t;i++)
{
printf("%d",prime[i]);
printf("\n");
}
getch();
}
/*out put:-
Enter the value  of n=10
Enter the array=
Enter number=10
Enter number=13
Enter number=25
Enter number=27
Enter number=73
Enter number=44
Enter number=53
Enter number=55
Enter number=12
Enter number=20
prime number  is=13
73
53
*/
Slip 12A.Write a  C program to calculate the x to the power y without using standard             function.
#include<stdio.h>
#include<conio.h>
void  main()
{  
int  i,x,y, ans;
clrscr();  
ans=1;  
printf("Enter  the value of x");
scanf("%d",  &x); 
printf("Enter  the value of y");
scanf("%d",  &y); 
for(i=1;  i<=y; i++) 
{  
ans=  ans*x; 
}  
printf("  %d to the power %d is %d", x, y, ans);
getch();  
}  
/* output
Enter the value  of x2
Enter the value  of y3
 2 to the power 3 is 8 */
12B.program name  Name Write a 'C' program to store the records of student
         (stud_no,stud_name,stud_addr,stud_percentage )in a file using structure.
#include<stdio.h>
#include<conio.h>
void  main()
{
  struct stud
{
int  sno;
float  per;
char  name[20],add[20];
}s;
  int i,n;
  char ch;
  FILE *fp;
  fp=fopen("a.txt","w");
  if(fp==NULL)
  {
  printf("\nUnable to open file!");
  }
  else
   {
     printf("\nEnter the stud no:->");
    scanf("%d",&s.sno);
    printf("\nEnter the stud  name:->");
    scanf("%s",s.name);
    printf("\nEnter the stud  add:->");
    scanf("%s",s.add);
    printf("\nEnter the stud  per:->");
    scanf("%f",&s.per);
     fprintf(fp,"%d\n%s\n%s\n%f",s.sno,s.name,s.add,s.per);
            }
  fclose(fp);
  getch();
}
/* output
Enter the stud  no:->1
Enter the stud  name:->amol
Enter the stud  add:->baramati
Enter the stud  per:->80*/
Slip 13A. Write a ‘C’ Program to accept a string  from user and  display the alternate characters                                                                                          
#include<stdio.h>
#include<conio.h>
void  main()
{
 char str[20];
int  i=0;
 clrscr();
printf("\n  enter the string");
scanf("\n  %s",str);
  for(i=0;i<strlen(str);i=i+2)
 {
   printf("%c",str[i]);
 }
 getch();
}
/* OUTPUT
 enter the string MAHARASHTRA
MHRSTA */
13B. Write a ‘C’ Program to sort elements of an array in ascending  order using 
         dynamic memory allocation
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void  main()
 {
 int a[5];
 int i,j,n,temp;
 clrscr();
 printf("\n enter the limit of  array");
 scanf("\n %d",&n);
a[i]=(int)  calloc(n,sizeof(int));
 printf("\n enter the array  element");
 for(i=0;i<n;i++)
  {
  scanf("\n %d",&a[i]);
  }
  for(i=0;i<n;i++)
   {
   for(j=i+1;j<n;j++)
            {
            if(a[i]>a[j]){
             temp=a[i];
             a[i]=a[j];
             a[j]=temp;
             }}}
   printf("\n the asending elements  are");
   for(i=0;i<n;i++)
            {
            printf("\n %d",a[i]);}
   getch();
  }
/* output
 enter the limit of array5
 enter the array element 56  8 34 1 78
 the asending elements are
 1
 8
 34
 56
 78
*/
Slip 14A. Write a C program to calculate the area of following:  -               
   i.  Circle
         i.             Rectangle
       ii.             Triangle           
#include<stdio.h>
#include<conio.h>
#include<math.h>
void  main()
{
 int ch;
 clrscr();
 while(1)
 {
 printf("\n1. For are of triangle");
 printf("\n2. For area of circle");
 printf("\n3. For area of  ractangle");
 printf("\n4. For are of square");
 printf("\n5.exit");
 printf("\nEnter your choice:");
 scanf("%d",&ch);
 switch(ch)
  {
 case 1:
  {
   int b,h,area;
   printf("Enter base and height:");
   scanf("%d%d",&b,&h);
   area=(b*h)/2;
   printf("The aree of  triangle=%d",area);
   break;
  }
 case 2:
  {
   float r,area;
   printf("Enter readius");
   scanf("%g",&r);
   area=3.14594*r*r;
   printf("\n area of  circle=%g",area);
   break;
  }
 case 3:
  {
   int l,b,area;
   printf("Enter lenght and  breadth:");
   scanf("%d%d",&l, &b);
   area=l*b;
   printf("Area of  rectangle:%d\n",area);
   break;
  }
 case 4:
  {
   int area,l;
   printf("Enter lenght:");
   scanf("%d",&l);
   area=l*l;
   printf("The are of  square:%d",area);
   break;
  }
 case 5:
  {
   exit(0);
               }
 }
 }
 getch();
}
/* output
1. For are of  triangle
2. For area of  circle
3. For area of  ractangle
4. For are of  square
5.exit
Enter your  choice:1
Enter base and  height:4
6
The aree of  triangle=12
1. For are of  triangle
2. For area of  circle
3. For area of  ractangle
4. For are of  square
5.exit
Enter your  choice:2
Enter readius4
 area of circle=50.335
1. For are of  triangle
2. For area of  circle
3. For area of  ractangle
4. For are of  square
5.exit
Enter your  choice:3 */
14B. Write a ‘C’  Program to count the number of characters, number of words and 
         number of lines from a text file and  display the result 
#include<stdio.h>
#include<conio.h>
void  main()
 {
 FILE *fp;
 char ch;
 int noc=0,now=0,nol=0,not=0;
 clrscr();
 fp=fopen("a.txt","r");
 if(fp==NULL)
  {
  printf("\n unable to open file");
  }
  while((ch=fgetc(fp))!=EOF)
   {
   if(ch==EOF)
   {
            break;
            }
            noc++;
            if(ch==' ')
            {
            now++;
            }
            if(ch=='\n')
            {
            nol++;
            }
            if(ch=='\t')
            {
            not++;
  }
  }
  fclose(fp);
  printf("\n the no of characters are  %d",noc);
  printf("\n the no of words are  %d",now+nol);
  printf("\n the no of lines are  %d",nol);
  printf("\n the no of tabs are  %d",not);
  getch();
 }
Slip 15A. program  to check whether given number is Palindrome or not.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int num,rem,sum=0,temp;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 temp=num;
 while(num>0)
  {
  rem=num%10;
  sum=rem+(sum*10);
  num=num/10;
  }
  if(temp==sum)
   {
   printf("\n number is palindrome");
   }
   else
            {
            printf("\n number is not  palindrome");
            }
  getch();
  }
/*output
 enter the value of num121
 number is palindrome */
15B. Write a ‘C’  Program to find the union and intersection of the two sets of integer 
     (Store it in two arrays) 
#include<stdio.h>
#include<conio.h>
void  main()
{
int  i,k=0,x[10],y[10],c[25],j,n,n1,d[25],f=0;
clrscr();
printf("\n  how many elements in SET 1:");
scanf("%d",&n);
printf("\n  please enter the elements" );
for(i=0;i<n;i++)
{
scanf("%d",&x[i]);
}
printf("\n  how many elements in set 2:");
scanf("%d",&n1);
printf("\n  please enter elements");
for(i=0;i<n1;i++)
{
scanf("%d",&y[i]);
}
for(i=0;i<n;i++)
{
c[k]=x[i];
k++;
}
for(i=0;i<n;i++)
{
for(j=0;j<n1;j++)
{
if(y[i]==x[j])
break;
}
if(j==n)
{
c[k]=y[i];
k++;
}
}
printf("\n  the union set is:");
for(i=0;i<k;i++)
printf("%d  ",c[i]);
for(j=0;j<n;j++)
{
for(i=0;i<n1;i++)
{
if(y[i]==x[j])
break;
}
if(i!=n1)
{
d[f]=y[i];
f++;
}
}
printf("\n  the intersection set is");
for(i=0;i<f;i++)
printf("%d  ",d[i]);
getch();
}
/* output
 how many elements in SET 1:5
 please enter the elements
11
44
22
88
32
 how many elements in set 2:5
 please enter elements
33
98
44
54
18
 the union set is:11  44   22  88  32   33  98  54  18
 the intersection set is 44 */
Slip 16A.  C program to check whether given number is  perfect or not.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int i,num,sum=0,temp;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 temp=num;
 for(i=1;i<=num;i++)
 {
  if(num%i==0)
   {
   sum=sum+i;
   }
}
  if(num==temp)
   {
   printf("\n the num is perfect");
   }
  getch();
 }
/* output
 enter the value of num6
 the num is perfect */
16B. Write a C  program to accept string from the user & replace all occurrences of
            character ‘a’ by ‘*’ symbol.*/
#include<stdio.h>
#include<conio.h>
void  main()
{
int  i=0,flag=0;
char  s[50];
clrscr();
printf("\n  enter the string:-");
gets(s);
while(s[i]!=NULL)
{
if(s[i]=='a')
{
s[i]='*';
}
i++;
}
printf("\n  the string is %s",s);
getch();
}
/* output
 enter the string:-a india
 the string is * indi*     */
Slip 17A.  program to generate following pattern for n lines.                         
A
B  B
C  C  C
D  D   D  D
E  E    E    E  E */
#include<conio.h>
#include<stdio.h>
void  main()
{
    int i,j,n;
    char c='A';
    clrscr();
    printf("\nEneter the no of lines to be  printed: ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       for(j=0;j<=i;j++)
       {
   printf("%c",c);
       }
       c++;
       printf("\n");
    }
    getch();
}
/* output
Eneter the no of  lines to be printed: 6
A
BB
CCC
DDDD
EEEEE
FFFFFF */
Slip 17B.  Program to accept ‘n’ numbers from user, store these numbers into an 
       array. Find out Maximum and Minimum  number from an Array(using function). 
#include<stdio.h>
#include<conio.h>
void  minmax(int a[5],int n);
void  main()
 {
 int a[5];
 int i,n,max,min;
 clrscr();
 printf("\n entre the limit of  array");
 scanf("\n %d",&n);
 printf("\n enter the array  element");
 for(i=0;i<n;i++)
  {
  scanf("\n %d",&a[i]);
  }
  minmax(a,n);
  getch();
  }
  void minmax(int a1[5],int n1)
  {
  int max,min,i;
  max=a1[0],min=a1[0];
 for(i=1;i<n1;i++)
  {
  if(a1[i]>max)
   {
   max=a1[i];
   }
   if(a1[i]<min)
   {
   min=a1[i];
   }
  }
  printf("\n the largest element is  %d",max);
  printf("\n the smallest element is  %d",min);
 }
/* output
 entre the limit of array5
. enter the  array element 67 56 1 45 234
 the largest element is 234
 the smallest element is 1  */
Slip 18A. Write  a C program to convert a given string into uppercase & vice versa. 
#include<stdio.h>
#include<conio.h>
#include<string.h>
void  main()
{
char  s1[20];
clrscr();
printf("\n  enter a string with upper and lowercase letters");
gets(s1);
printf("\The  string after converting to uppercase\t%s",strupr(s1));
printf("\n  The string after converting to lowercase\t%s",strlwr(s1));
getch();
}
/*Output
 enter a string with upper and lowercase  letters IndIA
The string after  converting to uppercase         INDIA
 The string after converting to lowercase        india */
18 B.C’ Program  to create student structure having fields roll_no, stud_name, 
       mark1,   mark2, mark3. Calculate the total and average of marks and arrange the 
      records in descending order of marks.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 struct student
 {
 int rollno;
 char name[20];
 int marks[3];
 int total;
 float avg;
 }stud[2];
 int i,j;
 struct student temp;
 clrscr();
 printf("\n enter studentinfo");
 for(i=0;i<2;i++)
  {
  printf("\n enter rollno");
  scanf("\n %d",&stud[i].rollno);
  printf("\n enter name");
  scanf("\n %s",&stud[i].name);
  stud[i].total=0;
  printf("\n enter marks");
  for(j=0;j<3;j++)
   {
   scanf("\n  %d",&stud[i].marks[j]);
   stud[i].total=stud[i].total+stud[i].marks[j]  ;
   stud[i].avg=stud[i].total/3;
   }
  }
  for(i=0;i<2;i++)
   {
   for(j=i+1;j<2;j++)
            {
            if(stud[i].total<stud[j].total)
             {
             temp=stud[i];
             stud[i]=stud[j];
             stud[j]=temp;
             }
            }
   }
   printf("\n the student info are");
            printf("\n ROLLNO    NAME TOTAL   AVG");
   for(i=0;i<2;i++)
            {
             printf("\n %d\t %s\t %d\t  %f",stud[i].rollno,stud[i].name,stud[i].total,stud[i].avg);
            }
  getch();
 }
/* output
 enter studentinfo
 enter rollno1
 enter nameajit
 enter marks 67 89 45
 enter rollno2
 enter nameamol
 enter marks67 99 99
 the student info are
 ROLLNO    NAME  TOTAL           AVG
 2        amol    265     88.000000
 1        ajit    201     67.000000 */
Slip 19A.  program to generate following pattern for n lines:
                                    1
                                    3          5
                                    7          9          11
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int i,j,temp=1,n;
 clrscr();
 printf("\n enter the number of  lines");
 scanf("\n %d",&n);
 for(i=1;i<=n;i++)
  {
   for(j=1;j<=i;j++)
   {
   printf("%d",temp);
   temp=temp+2;
   }
  printf("\n");
  }
  getch();
 }
/* output
 enter the number of lines3
1
3 5
7 9 11 */
19B. Program to  accept Book details of ‘n’ books as book_title, author,  publisher and cost. Assign the accession  number to each book in increasing order Display these details as
1.         Books of a specific author
2.         Books by a specific Publisher
3.         All Books costing Rs. 500 and above.
4.         All Books.                   (Using Structure Array)                                                                   
#include<stdio.h>
#include<conio.h>
#include<string.h>
void  main()
{
struct  book
{
 int bno,bcost,baccno;
 char bname[20],bpub[20],bauthor[20];
 }p[10];
  int n,i,f,ch;
  char pubname[20],authorname[20];
  clrscr();
  printf("Enter the limit of structure  array=");
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
            printf("Enter the book  no=");
            scanf("%d",&p[i].bno);
            flushall();
            printf("Enter the book  name=");
            gets(p[i].bname);
            flushall();
            printf("Enter the book  author=");
            gets(p[i].bauthor);
            printf("Enter the book  publication=");
            flushall();
            gets(p[i].bpub);
            printf("Enter the book  cost=");
            scanf("%d",&p[i].bcost);
            printf("Enter the book  accession number =");
            scanf("%d",&p[i].baccno);
  }
  while(1)
  {
  printf("\n1.Books of specific  author");
  printf("\n2.Books of specific  publisher");
  printf("\n3.All books costing Rs  500&above");
  printf("\n4.All books");
  printf("\n5.exit");
  printf("\nEnter the choice=");
  scanf("%d",&ch);
  switch(ch)
  {
            case 1:
             printf("Enter the author name you  want=");
             flushall();
             gets(authorname);
             f=0;
             for(i=0;i<n;i++)
             {
             if(strcmp(p[i].bauthor,authorname)==0)
             // if(f==0)
             {
            printf("\nBno=%d\tname=%s\taccession  no=%d",p[i].bno,p[i].bname,p[i],p[i].baccno);
             }
   }
             break;
   case 2:
             printf("Enter the publisher name=");
             flushall();
             gets(pubname);
             f=0;
             for(i=0;i<n;i++)
             {
                if(strcmp(p[i].bpub,pubname)==0)
                {
            printf("\nbno=%d\tbname=%s\tbpublisher=%s\taccession  no=%d",p[i].bno,p[i].bname,p[i].bpub,p[i].baccno);
                }
             }
             break;
  case 3:
             for(i=0;i<n;i++)
             {
               if(p[i].bcost>=500)
               {
               printf("\nbno=%d\nbname=%s\ncost=%d\t accession  no=%d",p[i].bno,p[i].bname,p[i].bcost,p[i].baccno);
             }
            }
             break;
  case 4:
             for(i=0;i<n;i++)
             {
                printf("\nbno=%d\nname=%s\nauthor=%s",p[i].bno,p[i].bname,p[i].bauthor);
                printf("\npublisher=%s\ncost=%d\t accession  no=%d",p[i].bpub,p[i].bcost);
             }
             break;
  case 5:
             exit(0);
             }
  }
  getch();
}
/* output
Enter the limit  of structure array=3
Enter the book  no=1
Enter the book  name=cprog
Enter the book author=kanetkar
Enter the book  publication=nirali
Enter the book  cost=150
Enter the book  accession number =1001
Enter the book  no=2
Enter the book  name=dbms
Enter the book  author=sharma
Enter the book  publication=vision
Enter the book  cost=678
Enter the book  accession number =1002
Enter the book  no=3
Enter the book  name=multimedia
Enter the book  author=sane
Enter the book  publication=bpb
Enter the book  cost=785
Enter the book  accession number =1003
1.Books of  specific author
2.Books of  specific publisher
3.All books  costing Rs 500&above
4.All books
5.exit
Enter the  choice=1
Enter the author  name you want=sharma
Bno=2   name=dbms       accession no=2
1.Books of  specific author
2.Books of  specific publisher
3.All books  costing Rs 500&above
4.All books
5.exit
Enter the  choice=2
Enter the  publisher name=nirali
bno=1   bname=cprog     bpublisher=nirali       accession no=1001
1.Books of  specific author
2.Books of  specific publisher
3.All books  costing Rs 500&above
4.All books
5.exit
Enter the  choice=3
bno=2
bname=dbms
cost=678         accession no=1002
bno=3
bname=multimedia
cost=785         accession no=1003
1.Books of  specific author
2.Books of  specific publisher
3.All books  costing Rs 500&above
4.All books
5.exit
Enter the  choice=4
bno=1
name=cprog
author=kanetkar
publisher=nirali
cost=150         accession no=1798
bno=2
name=dbms
author=sharma
publisher=vision
cost=678         accession no=1798
bno=3
name=multimedia
author=sane
publisher=bpb
cost=785         accession no=1798
1.Books of  specific author
2.Books of  specific publisher
3.All books  costing Rs 500&above
4.All books
5.exit
Enter the  choice=*/
Slip 20A. Write  a function is Even, which accepts an integer as parameter and returns 1 if the number  is even, and 0 otherwise. Use this function in main to accept n numbers and  check if they are even or odd.
#include<stdio.h>
#include<conio.h>
int  iseven(int num);
void  main()
 {
  int num,ans;
clrscr();
printf("\n  enter the value of num");
scanf("\n  %d",&num);
ans=iseven(num);
if(ans==1)
{
 printf("\n number is even");
}
if(ans==0)
{
 printf("\n number is odd");
}
getch();
}
int  iseven(int num1)
{
  if(num1%2==0)
    {
return  1;
}
else
{
return  0;
}
}
/* output
 enter the value of num7
number is odd */
20B. Write a C program for multiplication of  two matrices using dynamic memory     allocation
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void  main()
{
int  a[3][3],b[3][3],multi[3][3];
int  i,j,k,row,col;
clrscr();
printf("\n  enter the value of row")
scanf("\n  %d",&row);
printf("\n  enter the value of col")
scanf("\n  %d",&col);
a[i][j]=(int)calloc(n,sizeof(int));
printf("\n  enter first matrix-");
for(i=0;i<row;i++)
 {
 for(j=0;j<col;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }
printf("\n  enter the value of row")
scanf("\n  %d",&row);
printf("\n  enter the value of col")
scanf("\n  %d",&col);
b[i][j]=(int)calloc(n,sizeof(int));
printf("\n  enter second matrix-");
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d",&b[i][j]);
  }
 }
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
   multi[i][j]=0;
   for(k=0;k<3;k++)
  {
  multi[i][j]=multi[i][j]+(a[i][k]*b[k][j]);
  }
 }
}
printf("\n  the matrix multiplication is-");
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  printf("\t %d",multi[i][j]);
  }
 printf("\n");
}
getch();
}
/* Output
Enter first  matrix-  1 2 3 
                                  4 5 6 
                                  7 8 9 
Enter second  matrix-  1 2 3 
                                      4 5 6
                                      7 8 9
The matrix multiplication  is-30    36    42
                                                  66    81    96 
                                                  102  126  150  */
Slip 21A. Write a C program to  display multiplication table up to  10 number.   
#include  <stdio.h>
int  main()
{
    int n, i;
    printf("Enter an integer to find  multiplication table: ");
    scanf("%d",&n);
    for(i=1;i<=10;++i)
    {
        printf("%d * %d = %d\n", n,  i, n*i);
            }
            getch();;
}
/* iutput
Enter an integer  to find multiplication table: 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50 */
21B. A scooter company has serial numbers from  AA0  to  FF9, the other characteristics of scooter are year  of manufacture, colour, horsepower. Use a structure pointer and  do the  following:
a.         Retrieve all information of scooters  within a range BB0 and CC9
b.         Display the oldest scooter
#include<stdio.h>
#include<conio.h>
void  main()
 {
 struct scooter
          {
         char srno[5];
         int year;
         char color[10];    
         int hp;
           }sc[10];
int  i,ch,n;
clrscr();
while(1)
{
printf("\n  1:add scooter info");
printf("\n  2:information of scooters within a range BB0 and CC9");
printf("\n  3:Display the oldest scooter");
printf("\n  4:exit");
printf("\n  enter the choice");
scanf("\n  %d",&ch);
switch(ch)
{
 case 1:
            printf("\n how many record u  add");
                scanf("\n  %d",&n);
                                                  for(i=0;i<n;i++)
                                                            {
                                                            printf("\n  enter sr no");
                                                            scanf("\n  %s",&sc[i].srno);
                                                            printf("\n  enter year");
                                                            scanf("\n  %d",&sc[i].year);
printf("\n  enter color");
            scanf("\n  %s",&sc[i].color);
printf("\n  enter hp");
            scanf("\n  %d",&sc[i].hp);
}
break;
case  2: 
for(i=0;i<n;i++)
 {
            if(sc[i].srno>="bb0" ||  sc[i].srno<="cc9")
{
 printf("\n srno is%s",sc[i].srno);
printf("\n  year is%d",sc[i].year);
printf("\n  color is%s",sc[i].color);
printf("\n  hp is%d",sc[i].hp);
}
}
break;
case  3:printf("\n the oldest scooter is %c",sc[0]);
                        printf("\n srno  is%s",sc[0].srno);
printf("\n  year is%d",sc[0].year);
printf("\n  color is%s",sc[0].color);
printf("\n  hp is%d",sc[0].hp);
 break;
case  4:exit(0);
}
}
getch();
}
Slip 22A. Write  a program, which accepts a character from the user and checks if it is an 
                 alphabet, digit or punctuation  symbol. If it is an alphabet, check if it is uppercase 
                  or lowercase and then change  the case.                                                   
#include<stdio.h>
#include<conio.h>
void  main()
{
char  ch;
clrscr();
printf("\n  enter the character");
scanf("\n  %c",&ch);
if(ch>=65  && ch<=90 || ch>=97 && ch<=122)
{
printf("\n  the given character is alphabet");
if(ch>=65  && ch<=90)
{
 printf("\n character is uppercase");
}
else
{
   printf("\n character is  lowercase");
 }
 }
 if(ch>=48 && ch<=57)
 {
printf("  the given character is digit");
}
if(ch>=58  && ch<=64 || ch>=91 && ch<=96)
{
printf("\n  the given character is symbol");
 }
  getch();
  }
/* output
enter the  character B
 the given character is alphabet
 character is uppercase */
22B. Write a  C  program to calculate the sum of  following series using function.
         Sum=1+1/x+1/x2+1/x3+1/x4+………*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void  series(int x);
void  main()
{
  int x;
clrscr();
printf("\n  enter the value od x");
scanf("\n  %d",&x);
series(x);
getch();
}
void  series(int x1)
 {
   int i,limit;
   float sum=0;
   printf("\n enter the limit");
   scanf("\n %d",&limit);
  for(i=1;i<=limit;i++)
 {
  sum=sum+(1/(pow(x1 ,i)));
}
printf("\n  sum of series is %f",(1+sum));
getch();
}
/* output
 enter the value od x3
 enter the limit2
 sum of series is 1.444444 */
Slip 23A.  program to covert temperature from Celsius to Fahrenheit.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 float c,f;
 clrscr();
 printf("\n enter the value of c");
 scanf("\n %f",&c);
 f=(c*1.8)+32;
 printf("\n convert into fahrenfite %f  ",f);
 getch();
 }
23B. Write a C  program to accept two strings str1 and str2 and compare them.
         if they are equal display their  length. if str1 > str2 , convert str1 to uppercase
          and str2 to lowercase and display the  strings and vice versa.
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void  main()
{
char  str1[30],str2[30],copy[60];
int  cmp,length,ch;
clrscr();
            printf("\n Enter a string1  :");
            scanf("\n %s",&str1);
            printf("\n Enter a string2  :");
            scanf("\n %s",&str2);
            cmp=strcmp(str1,str2);
            if(strcmp(str1,str2)==0)
            {
            length=strlen(str1);
             printf("\n string are equals and length  is %d",length);
             }
             if(strcmp(str1,str2)>0)
                        {
                        printf("\n string1  is greater");
                        printf("\n string1  in uppercase is %s",strupr(str1));
                        printf("\n string2  in lowercase is %s",strlwr(str2));
                         }
               else
                        {
                         printf("\n string2 is greater");
                        printf("\n string2  in uppercase is %s",strupr(str2));
                        printf("\n string1  in lowercase is %s",strlwr(str1));
             }
getch();
}
/* output
 Enter a string1 :maharashtra
 Enter a string2 :india
 string1 is greater
 string1 in uppercase is MAHARASHTRA
 string2 in lowercase is india */
Slip 24A.  Program to swap two numbers using bitwise operator.
#include<stdio.h>
#include<conio.h>
void  main()
{
 int a,b,t;
 clrscr();
 printf("Enter the value of a=");
 scanf("%d",&a);
 printf("Enter the value of b=");
 scanf("%d",&b);
 a=a>>0;
 b=b<<0;
 t=a;
 a=b;
 b=t;
 printf("The swaped value of \n a=%d \n  b=%d",a,b);                       
getch();
}
/* output 
Enter the value  of a=34
Enter the value  of b=54                                                          
The swaped value  of                                                              
 a=54                                                                            
 b=34 */
24B. Write a  C  program to calculate sum of digits  till it reduces to a single digit 
          using recursion.   
#include<stdio.h>
#include<conio.h>
int  recsum(int n);
void  main()
{
  int n,ans;
  clrscr();
  printf("\n enter the number");
  scanf("\n %d",&n);
  ans= recsum(n);
 /* if(ans>9)
  {
   n=ans;
   ans=0;
   }
   */
   printf("\n sum is%d",ans);
   getch();
   }
   int recsum(int n1)
   {
             int rem,sum=0;
             if(n1==0)
                {
                          return 0;
                          }
                        else
                        {
                          rem=n1%10;
                          sum=rem+recsum(n1/10);
                         }
                          if(sum>9)
                          {
                           n1=sum;
                           sum=recsum(n1);
                           }
                          return sum;
                          }
/* output
 enter the number567
 sum is9   */
Slip 25A. Write a  C  program to accept n different numbers  and display sum of all +ve &  
                 -ve numbers.         
#include<stdio.h>
#include<conio.h>
main()
{
int  arr[10];
int  i,n,psum=0,nsum=0;
clrscr();
printf("\n  enter how many number u want");
scanf("\n  %d",&n);
printf("Enter  number=");
for(i=0;i<n;i++)
 {
  scanf("\n %d",&arr[i]);
            }
 for(i=0;i<n;i++)
 {
  if(arr[i]>0)
   {
psum=  psum+arr[i];
}
else
  {
  nsum= nsum+arr[i];
  }
  }
printf("\n  the sum of positive number is is=%d",psum);
printf("\n  the sum of negative number is is=%d",nsum);
getch();
}
/* output
 enter how many number u want5
Enter number=
12
-4
67
-3
-7
the sum of  positive number is is=79
the sum of  negative number is is=-14 */
25B. Write a  menu driven  program in C to create a  structure employee having fields empid , empname,salary. Accept  the details of n Employees  from user and perform the following  operations using function
             -   Search by EmpId
             - Display Names of Employee having salary is  greater than 10000
#include  <stdio.h>
#include  <conio.h>
void  main()
{
struct  details
{
 char name[30];
 int eid;
 int salary;
}emp[5];
int  n,i,id,ch;
 clrscr();
while(1)
{
printf("\n  1:add employee");
printf("\n  2:search employee");
printf("\n  3:Display Names of Employee having salary is greater than 10000 ");
printf("\n  4:exit");
printf("\n  enter the choice");
scanf("\n  %d",&ch);
switch(ch)
{
 case 1:
 printf("\n enter how many record u  add");
scanf("\n %d",&n);
printf("\n enter employee  record");
for(i=0;i<n;i++)
{
 printf("\nEnter name:");
 scanf("\n %s",&emp[i].name);
 printf("\nEnter id:");
 scanf("\n %d",&emp[i].eid);
 printf("\nEnter Salary:");
 scanf("\n %d",&emp[i].salary);
}
break;
case  2:
printf("\n enter the employee id u  search");
scanf("\n %d",&id);
for(i=0;i<n;i++)
 {
  if(emp[i].eid==id)
  {
    printf("\n employee id is  %d",emp[i].eid);
   printf("\n employee name is  %s",emp[i].name);
   printf("\n employee salary is  %d",emp[i].salary);
}
}
break;
case  3:
for(i=0;i<n;i++)
{
if(emp[i].salary>10000)
{
 printf("\n Name of the Employee : %s  ",emp[i].name);
 printf("\n id of the Employee : %d  ",emp[i].eid);
 printf("\n Salary of the Employee : %d  ",emp[i].salary);
}
}
break;
case  4:exit(0);
}
}
 getch();
}
/* output
 1:add employee
 2:search employee
 3:Display Names of Employee having salary is  greater than 10000
 4:exit
 enter the choice1
 enter how many record u add2
 enter employee record
Enter name:asha
Enter id:1
Enter  Salary:9950
Enter name:anita
Enter id:2
Enter  Salary:15000
 1:add employee
 2:search employee
 3:Display Names of Employee having salary is  greater than 10000
 4:exit
 enter the choice2
 enter the employee id u search2
 employee id is 2
 employee name is anita
 employee salary is 15000
 1:add employee
 2:search employee
 3:Display Names of Employee having salary is  greater than 10000
 4:exit
 enter the choice3
 Name of the Employee : anita
 id of the Employee : 2
 Salary of the Employee : 15000
 1:add employee
 2:search employee
 3:Display Names of Employee having salary is  greater than 10000
 4:exit
 enter the choice */
Slip 26A. Write  a program, which accepts a number n and displays each digit in 
         words.  Example: 6702 Output = Six-Seven-Zero-Two.        
#include<stdio.h>
#include<conio.h>
main()
{
int num,rem=0,digit;
clrscr();
printf("Enter number=");
scanf("%d",&num);
while(num>0)
{
rem=rem*10+num%10;
num=num/10;
}
while(rem>0)
{
digit=rem%10;
//rem=rem/10;
switch(digit)
{
case 1:printf("   one");
break;
case 2:printf("   two");
break;
case 3:printf("   three");
break;
case 4:printf("   four");
break;
case 5:printf("   five");
break;
case 6:printf("   six");
break;
case 7:printf("   seven");
break;
case 8:printf("   eight");
break;
case 9:printf("   nine");
}
}
getch();
return(0);
}
/*out put:-
Enter number=123
  one   two  three   */
26B. Write a C program to display transpose of matrix using user  defined function.
#include<stdio.h>
#include<conio.h>
void  transpose(int a[3][3],int n);
void  main()
{
int  a[3][3],trans[3][3];
int  i,j,n;
clrscr();
printf("\n  enter the limit");
scanf("\n  %d",&n);
printf("\n  enter the array element-");
for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }
  transpose(a,n);
getch();
}
void  transpose(int a1[3][3],int n1)
{
   int trans[3][3];
   int i,j;
for(i=0;i<n1;i++)
 {
 for(j=0;j<n1;j++)
  {
  trans[i][j]=a1[j][i];
  }
 }
printf("\n  the transpose of matrix is\n-");
for(i=0;i<n1;i++)
 {
 for(j=0;j<n1;j++)
  {
  printf("\t %d",trans[i][j]);
  }
 printf("\n");
}
getch();
}
/* Output
 enter the limit-3
 enter the array element-
        1 2 3
        4 5 6
        7 8 9
 the transpose of matrix is
         1        4       7
         2        5       8
         3        6       9 */
Slip 27A. C  program to calculate sum of all even numbers in an array.
#include<stdio.h>  
#include<conio.h>
void  main()
{
int  a[5];
int  i,sum=0;
clrscr();
printf("\n  enter the array element-");
for(i=0;i<5;i++)
 {
 scanf("\n %d",&a[i]);
 }
for(i=0;i<5;i++)
 {
   if(a[i]%2==0)
            {
               sum=sum+a[i];
               }
 }
printf("\n  the sum of even number is %d",sum);
getch();
}
/* output
 enter the array element-
22
55
34
79
11
 the sum of even number is 56 */
27B. Write a C  program to create structure student   having fields Rollno, Name. Accept the     details of students from the user store it  into the file and Calculate the size of File.
#include<stdio.h>
#include<conio.h>
void  main()
{
  struct stud
            {
            int sno;
            float per;
            char name[20],add[20];
             }s;
  int i,n;
int  size = 0;
  char ch;
  FILE *fp;
  fp=fopen("a.txt","w");
  if(fp==NULL)
  {
  printf("\nUnable to open file!");
  }
  else
   {
    printf("\nEnter the stud  no:->");
    scanf("%d",&s.sno);
    printf("\nEnter the stud  name:->");
    scanf("%s",s.name);
     fprintf(fp,"%d\n%s",s.sno,s.name);
            }
  fseek(fp, 0, 2);    /* file pointer at the end of file */
  size = ftell(fp);   /* take a position of file pointer un size  variable */
  printf("The size of given file is :  %d\n", size);    
  fclose(fp);
  getch();
}  
/* output
Enter the stud  no:->11
Enter the stud  name:->asha
The size of  given file is : 8    */
Slip 28A. Write a C program to accept string  from user and display alternate character of 
           string in upper case .(eg: I/P  hello O/P hElLo)
#include<stdio.h>
#include<conio.h>
void  main()
{
            char str[30];
            int i;
            clrscr();
            printf("\n enter the  string");
            gets(str);
    for(i = 0; str[i] != 0; i++)
    {
        if( (i % 2) == 0)
            str[i] = tolower(str[i]);
        else
            str[i] = toupper(str[i]);
    }
    printf("%s\n", str);
getch();
}
28B. C program  to accept n employee information(eno, enme, salary) and 
        display  the employee information having maximum salary. Use array of structure 
#include<stdio.h>
#include<conio.h>
void  main()
 {
 struct employee
 {
 int eno;
 char ename[20];
 int salary;
 }emp[3];
 int i,j,max;
 clrscr();
 printf("\n enter employee info");
 for(i=0;i<2;i++)
  {
  printf("\n enter employeeno");
  scanf("\n %d",&emp[i].eno);
  printf("\n enter name");
  scanf("\n %s",&emp[i].ename);
  printf("\n enter employee salary");
  scanf("\n %d",&emp[i].salary);
  }
  max=emp[0].salary;
  for(i=0;i<2;i++)
   {
            if(emp[i].salary>max)
             {
            max=emp[i].salary;
             }
            }
   printf("\n the employee who have  maximum salary  is");
            printf("\n EMPNO    NAME   SALARY");
   for(i=0;i<2;i++)
            {
            if(emp[i].salary==max)
            {
             printf("\n %d\t %s\t  %d",emp[i].eno,emp[i].ename,emp[i].salary);
            }
            }
  getch();
 }
/* output
 enter employee info
enter  employeeno=1
enter name=asha
 enter employee salary=10000
 enter employeeno=2
 enter name=anita
enter employee  salary=15000
 the employee who have maximum salary  is
 EMPNO     NAME  SALARY
 2        anita   15000*/
Slip 29A. Write a C program to check whether a given number is  palindrome or not.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int num,rem,sum=0,temp;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 temp=num;
 while(num>0)
  {
  rem=num%10;
  sum=rem+(sum*10);
  num=num/10;
  }
  if(temp==sum)
    {
    printf("\n number is palindrome");
    }
   else
    {
    printf("\n number is not  palindrome");
    }
  getch();
  }
/*output
 Enter the value of num=121
 Number is palindrome */
29B. Write a  C  program to accept three integers as  command line arguments and find    
         the minimum, maximum and average of  the three numbers. Display error message 
         if the number of arguments entered are  invalid
#include<stdio.h>
#include<conio.h>
void  main(int argc , char * argv[])
{
            int i,sum=0;
            float avg;
            int max;
            int min;
            clrscr();
            if(argc!=4)
               {
               printf("you have forgot to type numbers.");
               exit(1);
               }  
            for(i=1;i<argc;i++)
             {
                        sum = sum +  atoi(argv[i]); 
                        avg=sum/3;
                        }
             printf("the average is%f",avg);
             //for max
             max=argv[1];
             min=argv[1];
                        for(i=1;i<argc;i++)
                          {
                        if(atoi(argv[i])>max)
                         {
                         max=atoi(argv[i]);
                         }
                         }
                             if(atoi(argv[i])<min)
                         {
                         min=atoi(argv[i]);
                         }
   printf("\n the maximum number is %d",max);
              printf("\n  the minimum number is %d",min);
                          getch()
}
Slip 30A.  program to check whether given number is Palindrome or not.
#include<stdio.h>
#include<conio.h>
void  main()
 {
 int num,rem,sum=0,temp;
 clrscr();
 printf("\n enter the value of num");
 scanf("\n %d",&num);
 temp=num;
 while(num>0)
  {
  rem=num%10;
  sum=rem+(sum*10);
  num=num/10;
  }
  if(temp==sum)
   {
   printf("\n number is palindrome");
   }
   else
            {
            printf("\n number is not  palindrome");
            }
  getch();
  }
/*output
 enter the value of num121
number  is palindrome */
30B. Write menu  driven program to convert decimal number in to binary, octal and                       hexadecimal.Write  separate user defined function for each option. 
#include<stdio.h>
#include<conio.h>
#include<math.h>
int  D2B(int);
int  D2O(int);
int  D2H(int);
main()
{
  int ch,num;
  clrscr();
  while(1)
  {
  printf("\n1.Decimal 2 Binary.");
  printf("\n2.Decimal 2 Octal.");
  printf("\n3.Decimal 2 Hexa.");
  printf("\n4.Exit.");
  printf("\nEnter your Choice:");
  scanf("%d",&ch);
  switch(ch)
   {
     case 1:
          clrscr();
          printf("\nEnter any Decimal  number:");
                          scanf("%d",&num);
                          D2B(num);   //calling functione
                          break;
             case 2:
                          clrscr();
                          printf("\nEnter any Decimal  number:");
                          scanf("%d",&num);
                        D2O(num);  //calling function
                      break;
    case 3:
          clrscr();
          printf("\nEnter any Decimal  number:");
                          scanf("%d",&num);
                        D2H(num);  //calling function
                        break;
  case 4:
          exit(0);
   }
   }
 getch();
}
int  D2B(int dec) //decimal to binary
{
  int bin=0,*bin_arr,count=0;
  while(dec>0)
   {
             bin=dec%2;
             dec/=2;
             *(bin_arr+count)=bin;
             count++;
   }
  printf("\nBINARY=");
  while(count > 0)
   {
    --count;
    printf("%d",*(bin_arr+count));
   }
   return 0;
}
int  D2O(int dec) //decimal to octal
{
  int oct=0,*oct_arr,count=0;
  while(dec>0)
   {
     oct=dec%8;
     dec/=8;
     *(oct_arr+count)=oct;
     count++;
   }
  printf("\nOCTAL=");
  while(count > 0)
   {
    --count;
    printf("%d",*(oct_arr+count));
   }
   return 0;
}
int  D2H(int dec) //decimal to hexa
{
  int hexa=0,*hexa_arr,count=0;
  while(dec>0)
   {
     hexa=dec%16;
     dec/=16;
     *(hexa_arr+count)=hexa;
     count++;
   }
  printf("\nHEXA=");
  while(count > 0)
   {
    --count;
     switch(*(hexa_arr+count))
     {
       case 10:
            printf("A");
            break;
       case 11:
            printf("B");
            break;
       case 12:
            printf("C");
            break;
       case 13:
            printf("D");
            break;
       case 14:
            printf("E");break;
       case 15:
            printf("F");break;
       default:
             printf("%d",*(hexa_arr+count));
            break;
     }
       }
}
 
