SlideShare a Scribd company logo
PART- A
1a. WAP to find the area of the triangle



#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

float a,b,c,area,s;//s is semi perometer i.e. s=(a+b+c)/2

clrscr();

printf("enter the three sides of triangle");

scanf("%f%f%f",&a,&b,&c);

if((a+b)>c&&(a+c)>b&&(b+c)>a)

{

s=(a+b+c)/2;

area=sqrt(s*(s-a)*(s-b)*(s-c)) ;

printf("the area of given triangle is-->%f",area);

}

else

printf("the sides given are invalid...enter vaild sides");

getch();

}
Output
enter the three sides of triangle

1

1

1

the area of given triangle is-->0.433013




    1b. Wap to find the area of the circle



#include<stdio.h>

#include<conio.h>

void main()

{

float p=3.14,r,area;

clrscr();

printf("Enter the value of radious = ");

scanf("%f",&r);

area=p*r*r;

printf("nThe area of circle is = %f",area);

getch();

}
Output
Enter the value of radious = 2



The area of circle is = 12.560000




2. Wap to find the simple interest ,given the principle,time and rate of
interest with appropriate validation

#include<stdio.h>

#include<conio.h>

void main()

{

    int p,t;

    float r,si;

    clrscr();

    printf("n enter principle,rate and time");

    scanf("%d%f%d",&p,&r,&t);

    si=(p*r*t)/100;

    printf("n simple interest:%f",si);

    getch();

}


Output

Enter the year which you know to check that it is leap year or not:->2008

The given year is leap year
3. WAP to check whether the given year is leap year or not



#include<stdio.h>

#include<conio.h>

void main()

{

int n;

clrscr();

printf("n Enter the year which you know to check that it is leap year or not:->");

scanf("%d",&n);

if((n%400==0)||(n%4==0)&&(n%100!=0))

{

     printf("n The given year is leap year");

}

else

{

    printf("n The given year is not a leap year");

}

getch();

}
4. WAP to find the root of the quadratic equation with appropriate
message.




//roots of the quadratic equation

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

    int a,b,c,d=0,rp,ip;

    float x1,x2,e;

    clrscr();

    printf("n enter the coefficient of a,b and c");

    scanf("%d%d%d",&a,&b,&c);



    if(a>0)

    {

           d=b*b-4*a*c;



           if(d==0)

           {

               printf("n roots are equal");

               x1=x2=-b/(2*a);

               printf("n root 1=%f",x1);

               printf("n root 2=%f",x2);
}

         else if(d>0)

          {

          e=sqrt(d);

             printf("n roots are real");

             x1=-(b+e)/(2*a);

             x2=-(b+e)/(2*a);

             printf("n root 1=%f",x1);

             printf("n root 2=%f",x2);

             }

         else

             {

                 printf("root are imaginary");

             }



              }



else

{

    printf("n this is not a quadratic equation");

}

     getch();

    }
6. WAP to find GCD and LCM of given two numbers
#include<stdio.h>

#include<conio.h>

void main()

{

    int u,v,temp,a,b,lcm,gcd;

    clrscr();

    printf("n enter two number");

    scanf("%d%d",&u,&v);

    a=u;

    b=v;

    while(v!=0)

    {

        temp=u%v;

        u=v;

        v=temp;

    }

    gcd=u;

    lcm=(a*b)/gcd;

    printf("n GCD of two number=%d",gcd);

    printf("n LCM of the two number=%d",lcm);

    getch();

}
7. WAP to calculate sin(x) series.
#include<stdio.h>

#include<conio.h>

void main()

{

    int n,sign=1,i;

    float x,t,sum;

    clrscr();

    printf("n enter value of x and n");

    scanf("%f%d",&x,&n);

    x=(3.14 /180)*x;

    sum=t=x;

    for(i=1;i<n;i++)

    {

           sign=-1;

           t=sign*t*x*x/(2*i*(2*i+1));

           sum=sum+t;

    }

    printf("sum of sin x series=%f",sum);

    getch();

}
8. WAP to print all prime numbers between m and n

#include<stdio.h>

#include<conio.h>

void main()

{

    int m,n,i,j,prime=0;

    clrscr();

    printf("n enter two number from which you want to check prime number");

    scanf("%d%d",&m,&n);

    if(m<2)

        m=2;



    for(i=m;i<=n;i++)

    {

        prime=1;

        for(j=2;j<=i-1;j++)



               if (i%j==0)

                {

                prime=0;

                break;

                }

                if(prime)

                    printf("n %dt",i);
}

    getch();

}


9. WAp to reverse a number and check whether it is palindrome or not
#include<stdio.h>

#include<conio.h>

void main()

{

    int n,d,r=0,u=0;

    clrscr();

    printf("n enter a number");

    scanf("%d",&n);

    u=n;

    while(n!=0)

    {

    d=n%10;

    r=(r*10)+d;

    n=n/10;

    }

        if (r==u)

               printf("n number is palindrome");

        else

               printf("n number is not palindrome");



        getch();
}

10 WAP to generate and print first n Fibonacci numbers using function.
#include<stdio.h>

#include<conio.h>

    void fibo(int);

    void main()

    {

        int n;

        clrscr();

        printf("n enter the limit of the seriesn");

        scanf("%d",&n);

        fibo(n);

        getch();

    }

    void fibo(int n)

    {

        int a=0,b=1,c,i=3;



        printf("n fibonacci series=n");

        if(n<1)

        printf("enter the valid limit");

        else

        if(n==1)

        printf("0");

        else if(n==2)

        printf("%dt%d",a,b);
else

     {

     printf("0 t 1");

     while(i<=n)

     {

         c=a+b;

         printf("t%d",c);

         a=b;

         b=c;

         i++;

     }

     }

 }

11 WAP to find factorial of a given number usind recursive function.
#include<stdio.h>

#include<conio.h>

     int factorial();

     void main()

     {

                int n;

                clrscr();

                printf("n enter a numbern");

                scanf("%d",&n);

                printf("n factorial=%d",factorial(n));

                getch();

     }
int factorial(int n)

    {

        if(n==0)

        {

                 return(1);

        }

        else

        {

                 return(n*factorial(n-1));

        }

    }

12 WAP to convert upper case alphabets to lower case alphabets in the given
string and vice versa.
#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

        char str[20];

        int i;

        clrscr();

        puts("enter a stringn");

        gets(str);

        printf("n original string=%s",str);

        for(i=0;str[i]!='0';i++)

        {
if(str[i]>='A' && str[i]<='Z')

            {

                str[i]=str[i]+32;

            }



           else

            if(str[i]>='a' && str[i]<='z')

            {

                str[i]=str[i]-32;

            }

    }



    printf("n change string is:%s",str);

    getch();

}

13 write a program to read two strings and concatenate them (without using
library function).
#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

    char str1[20],str2[10];

    int i=0,j=0;

    clrscr();

    puts("enter string first");
gets(str1);

   puts("n enter string second");

   gets(str2);

   while(str1[i]!='0')

   {

        str1[i++];

   }

   while(str2[j]!='0')

   {

        str1[i]=str2[j];

        str1[i++];

        str2[j++];

        str1[i]='0';

   }

        printf("concaneted string=");

        puts(str1);

        getch();

   }

14 WAP to read a sentence and count the number of vovel and consonant.



PART -B
   1. WAP to read N integer (zero,+ve and -ve) into an arrey and find the
      sum of positive numbers, sum of negative numbers and average of
      all input numbers
#include<stdio.h>
#include<conio.h>

 void main()

 {

          int a[20],n,i,sum1=0,sum2=0;

     float avg=0.0;

     clrscr();

     printf("n enter the size of the arrayn");

     scanf("%d",&n);

     printf("enter array element 1 by 1 n ");

     for(i=0;i<n;i++)

           scanf("%d",&a[i]);

     for(i=0;i<n;i++)

           {

           if(a[i]>0)

                 sum1=sum1+a[i];

            else

                 sum2=sum2+a[i];

           }

     avg=(sum1+sum2)/n;

     printf("n sum of posotive number=%d",sum1);

     printf("n sum of negative number =%d",sum2);

     printf("n average on entered number =%f",avg);

     getch();

     }
2. WAP to input N real numbers and to find the mean , variance and
        standard deviation

#include<stdio.h>

#include<conio.h>

#include<math.h>

 void main()

 {

     float a[20],sum=0.0,mean=0.0,var,sumsqr,dev;

     int n,i;

     clrscr();

     printf("n enter the size of the arrayn");

     scanf("%d",&n);

     printf("enter array element 1 by 1 n ");

     for(i=0;i<n;i++)

     {

           scanf("%f",&a[i]);

            sum=sum+a[i];

     }

     mean=sum/n;

     for(i=0;i<n;i++)

           sumsqr=sumsqr+((a[i]-mean)*(a[i]-mean));

           var=sumsqr/n;

           dev=sqrt(var);

           printf("n mean of entered number =%f",mean);

           printf("n variatiuon=%f",var);
printf("n deviation=%f",dev);

         getch();

         }


         3. WAP to input N numbers and store them in an array and apply
            linear search
#include<stdio.h>

#include<conio.h>

void main()

{

    int a[20],item,i,flag=0;

    int n;

    clrscr();

    printf("n enter size of the arrayn");

    scanf("%d",&n);

    printf("n enter array element 1 by 1 n");

    for(i=0;i<n;i++)

     scanf("%d",&a[i]);

    printf("n enter a searching numbern");

    scanf("%d",&item);

    for(i=0;i<n;i++)



     if(item==a[i])

     {

         flag=1;

         break;
}



 if(flag)

 printf("n searching number %d is found at %d position",item,i+1);

 else

         printf("n searching value not found");

 getch();

 }




         4. WAP to sort N numbers is ascending order or descending order
            using bubble sort

#include<stdio.h>

#include<conio.h>

     void main()

     {

             int a[10],i,j,n,temp;

             clrscr();

             printf("n enter the size of the arrayn");

             scanf("%d",&n);

             printf("n enter the array element 1 by 1 n");

             for(i=0;i<n;i++)

              scanf("%d",&a[i]);

              printf("n after insertion array is n");

              for(i=0;i<n;i++)
printf("%dt",a[i]);

      for(i=0;i<n-1;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 after sorting in ascending order array isn");

               for(i=0;i<n;i++)

                   printf("%dt",a[i]);

           getch();

           }


      5. WAP to implement binary search

//binary searching

#include<stdio.h>

#include<conio.h>

  void main()

  {

          int a[10],i,j,n,temp,item,ub,lb,mid,found=0;

          clrscr();

          printf("n enter the size of the arrayn");

          scanf("%d",&n);
printf("n enter the array element 1 by 1 in ascending ordern");

    for(i=0;i<n;i++)

     scanf("%d",&a[i]);

    printf("n after insertion array is n");

    for(i=0;i<n;i++)

         printf("%dt",a[i]);

for(i=0;i<n-1;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 enter a searching numbern");

         scanf("%d",&item);

         lb=0;

         ub=n-1;

         while(lb<ub)

         {

                  mid=(lb+ub)/2;

                  if(item==a[mid])

                  {

                      found=1;

                      break;
}

     if(item<a[mid])

             ub=mid-1;

     else

             lb=mid+1;

     }

     if(found)

         printf("n searching value is found at %d position",mid+1);

     else

     printf("n searching value not found");

     getch();

    }


6. WAP to read two matrices A & B of size M*N and perform product
   of two given matrices.
  #include<stdio.h>
  #include<conio.h>
  int main()
  {
    int a[' '][' '],b[' '][' '],c[' '][' '],i,j,k,m1,n1,m2,n2;
    clrscr();
    printf("n enter the order of the first matrix");
    scanf("%d%d",&m1,&n1);
    printf("n enter the order of the second matrix");
    scanf("%d%d",&m2,&n2);
    if(m1!=n2)
    {
    printf("multiplication not possible");
    getch();
    return 0;
    }

   printf("n enter matrix 1 element 1 by 1");
for(i=0;i<m1;i++)
   {
     for(j=0;j<n1;j++)
      {
          scanf("%d",&a[i][j]);
      }
    }
  printf("n enter matrix 2 element 1 by 1");
  for(i=0;i<m2;i++)
   {
     for(j=0;j<n2;j++)
     {
          scanf("%d",&b[i][j]);
     }
   }
  printf("n matrix 1 isn");
  for(i=0;i<m1;i++)
  {
    for(j=0;j<n1;j++)
           printf("%dt",a[i][j]);
           printf("n");
    }
    printf("n matrix 2 is n");
    for(i=0;i<m2;i++)
    {
          for(j=0;j<n2;j++)
              printf("%dt",b[i][j]);
              printf("n");
    }
// multiplication start
  for(i=0;i<m1;i++)
    {
          for(j=0;j<n1;j++)
          {
              c[i][j]=0;
              for(k=0;k<m1;k++)
              c[i][j]=c[i][j]+a[i][k]*b[k][j];
            }
          }
          printf("n after multip[lication matrix 3 is n");
          for(i=0;i<m1;i++)
          {
for(j=0;j<n2;j++)
                            printf("%dt",c[i][j]);
                            printf("n");
                         }
                         getch();     
                         return 0;
                     }


         7. WAP to list the name of the students who have scored more than
         60% of total marks in three subject using str var

#include<Stdio.h>

#include<conio.h>

struct student

{

    int usn;

    char name[10];

    int marks[3];

    int total;

};

struct student s[5];

    void main()

    {

        int i,j,n;

        clrscr();

        printf("n enter the number of the studentn");

        scanf("%d",&n);

        for(i=0;i<n;i++)

    {
printf("n enter the details of %d studentn",i+1);

printf("enter student usnn");

scanf(" %d",&s[i].usn);

printf("n enter student namen");

scanf("%s",&s[i].name);

printf("n enter three paper marks 1 by 1 n");

for(j=0;j<3;j++)

{

    scanf("%d",&s[i].marks[j]);

    s[i].total=s[i].total+s[i].marks[j];

}

}

        clrscr();

printf("n n student details (scored more than 60%).....");

printf("n ..........");

for(i=0;i<n;i++)

{

         if(s[i].total>=180)

         {

             printf("n usn no.=%d",s[i].usn);

             printf("n student name=%s",s[i].name);

             printf("n total marks=%d",s[i].total);

         }

         printf("nnn");

}
getch();

     }


8 WAP to compute the sum of two complex number-passing a structure
to a function.
#include<stdio.h>

#include<conio.h>

struct complex

{

     int real,imag;

};

typedef struct complex s;

void main()

{

    s x,y;

    clrscr();

    printf("n enter the first complex number");

    printf("n enter real part=");

    scanf("%d",&x.real);

    printf("n enter the imaginary part=");

    scanf("%d",&x.imag);

    printf("n enterthe second imaginary part");

    printf("n enter real part=");

    scanf("%d",&y.real);

    printf("n enter imaginary part=");

    scanf("%d",&y.imag);
printf("n addition of two complex number
is=(%d+i%d)+(%d+i%d)=(%d+i%d)",x.real,x.imag,y.real,y.imag,x.real+y.real,x.imag+y.imag);

     getch();

}


9. Define a book structure having book info . WAP to accept date and list
out all the book infopublished during date.
#include<stdio.h>

#include<conio.h>

struct date

{

     int month;

     int year;

};

typedef struct date pdate;

struct book

{

      int isbn;

      char title[20];

      char author[20];

      int price;

      pdate date;

};

typedef struct book books;

     void main()

     {

         pdate search;
books mca[20];

int n,i;

clrscr();

printf("n enter how many xbookst");

scanf("%d",&n);

for(i=0;i<n;i++)

{

      printf("n enter the details of %d books n",i+1);

      printf("n enter the isbn number t");

      scanf("%d",&mca[i].isbn);

      printf("n enter the name of the bookt");

      scanf("%s",mca[i].title);

      printf("n enter the author namet");

      scanf("%s",mca[i].author);

      printf("n enter the price of the bookt");

      scanf("%d",&mca[i].price);

      printf("n enter the mounth of the publicationt");

      scanf("%d",&mca[i].date.month);

      printf("n enter the year of the publicationt");

      scanf("%d",&mca[i].date.year);

}

printf("n enter the month of publication that to searcht");

scanf("%d",&search.month);

printf("n enter the year of publication to searcht");

scanf("%d", &search.year);
printf("nn book datails.....n");

         for(i=0;i<n;i++)

         {

              if((mca[i].date.month==search.month)&&(mca[i].date.year==search.year))

              {

                  printf("n title=%s",mca[i].title);

                  printf("n isbn=%d",mca[i].isbn);

                  printf("n author name=%s",mca[i].author);

                  printf("n price of the book=%d",mca[i].price);

                  printf("n month of publication=%d",mca[i].date.month);

                  printf("n year of publication=%d",mca[i].date.year);

              }

         }

         getch();

     }


10. define structure having students info with 5 sub marks using array,
list out all the failed students.
#include<stdio.h>

#include<conio.h>

struct student

{

    char name[20];

    int usn,tot,sub[5];

};

    void main()
{

    int i,n,j;

    struct student std[10];

    clrscr();

    printf("n enter the number of the student t");

    scanf("%d",&n);

    printf("n enter the student details..");

    for(i=0;i<n;i++)

    {

        std[i].tot=0;

        printf("n enter name of the %d student=t",i+1);

        scanf("%s",std[i].name);

        printf("n enter usn of the %d student=t",i+1);

        scanf("%d",&std[i].usn);

        printf("n enter marks of the %d student==t",i+1);

        for(j=0;j<5;j++)

        {

                printf("n enter subject %d markst",j+1);

                scanf("%d",&std[i].sub[j]);

                while(std[i].sub[j]>100)

                {

                    printf("marks over flow n reemter the markst");

                    scanf("%d",&std[i].sub[j]);

                }

                std[i].tot+=std[i].sub[j];
}

     }

     printf("n list of failed studentsn");

     for(i=0;i<n;i++)

     {

              if(std[i].tot<200)

              {

                  printf("n name=%st",std[i].name);

                  printf("n usn=%dt",std[i].usn);

                  printf("n total=%d",std[i].tot);

              }

     }

     getch();

 }


11. WAP to find the sum of n integers in an array using pointers.
#include<stdio.h>

#include<conio.h>

 void main()

 {

         int n,arr[10],i,*p,sum=0;

         p=arr;

         clrscr();

         printf("n enter the size of the arrayn");

         scanf("%d",&n);

         printf("n enter %d numbern",n);
for(i=0;i<n;i++)

       {

                scanf("%d",&arr[i]);

       }

       for(i=1;i<=n;i++)

       {

                sum=sum+*p;

                *p++;

       }

       printf("n sum of all the number =%d",sum);

       getch();

      }


12. WAP to read and write to a file.
#include<stdio.h>

#include<conio.h>

FILE *fp;

void main()

{

    char name[20];

    int usn,marks,n,i;

    clrscr();

    fp=fopen("student.dat","w");

    printf("n how many student records you want to enter t");

    scanf("%d",&n);

    for(i=1;i<=n;i++)
{

        printf("n enter %d student name t",i);

        scanf("%s",&name);

        printf("n enter %d student usn t",i);

        scanf("%d",&usn);

        printf("n enter %d student marks t",i);

        scanf("%d",&marks);

        fprintf(fp,"%st%dt%dn",name,usn,marks);

    }

    fclose(fp);

    fp=fopen("student.dat","r");

    printf("students records are n");

    for(i=1;i<=n;i++)

    {

        fscanf(fp,"%s%d%d",&name,&usn,&marks);

        printf("nnn name of %d student=%s",i,name);

        printf("n usn of %d student=%d",i,usn);

        printf("n marks of %d student=%d",i,marks);

    }

    fclose(fp);

    getch();

}


13. wap to creat and count number of character in a file.
#include<stdio.h>

    void main()
{

    FILE *f;

    char fname[20],c;

    int ctr=0;

    clrscr();

    f=fopen("rj","w");

    fclose(f);

    printf("n enter the file name to openn");

    scanf("%s",fname);




    f=fopen("fname","r");

    if (!f)

        printf("n file not exist..permission denied");

    else

        {

                  c=getc(f);

                  for(;getc(f)!=EOF;ctr++)

                  {

                  }

                  printf("n total count of character is %d",ctr);

              }

        getch();



    }
14. WAP to handle file with mixed data type.
#include<stdio.h>

struct emp

{

    char name[20];

    int empno;

    float sal;

    char status[10];

    };

    void main()

    {

        typedef struct emp s;

        s s1;

        FILE *f;

        clrscr();

        f=fopen("deepak.txt","w");

    /* if(!f)

        puts("file not exist.permission denied");

        else

        { */

         printf("...employee details......n");

         printf("n enter the employee name=");

         scanf("%s",s1.name);

         //fflush(stdin);

         printf("n enter the employee number =");

         scanf("%d",&s1.empno);
printf("n enter employee salary=");

    scanf("%f",&s1.sal);

// fflush(stdin);

    printf("n enter the employee status=");

    scanf("%s",s1.status);

// fprintf(f,"%s%d%f%c",s1.name,s1.empno,s1.sal,s1.status);

    fclose(f);

    f=fopen("deepak.txt","r");

// fscanf(f,"%s%d%f%c",s1.name,&s1.empno,&s1.sal,s1.status);

    printf("n name=%s",s1.name);

    printf("n emp number =%d",s1.empno);

    printf("n employee salary=%f",s1.sal);

    printf("n employee status=%s",s1.status);

    fclose(f);



    getch();

}

More Related Content

What's hot

DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
C basics
C basicsC basics
C basicsMSc CST
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structuresvinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)vinay arora
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Stringsvinay arora
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
Sazzad Hossain, ITP, MBA, CSCA™
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
Sushil Mishra
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
Daa practicals
Daa practicalsDaa practicals
Daa practicals
Rekha Yadav
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
Harjinder Singh
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
C file
C fileC file
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
Dr.M.Karthika parthasarathy
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
ArghodeepPaul
 
C programs
C programsC programs
C programsMinu S
 

What's hot (20)

DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
C basics
C basicsC basics
C basics
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Strings
 
C Programming
C ProgrammingC Programming
C Programming
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
Daa practicals
Daa practicalsDaa practicals
Daa practicals
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
C file
C fileC file
C file
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
C programs
C programsC programs
C programs
 

Viewers also liked

Defeating Windows memory forensics
Defeating Windows memory forensicsDefeating Windows memory forensics
Defeating Windows memory forensicslmilkovic
 
Enoek Alves Application1
Enoek Alves Application1Enoek Alves Application1
Enoek Alves Application1Enoek Alves
 
Prezentacja michał błachnio
Prezentacja michał błachnioPrezentacja michał błachnio
Prezentacja michał błachnioMblachnio9845
 
Diane goodman Herdsa 2013 subm
Diane goodman Herdsa 2013 submDiane goodman Herdsa 2013 subm
Diane goodman Herdsa 2013 submDiane Goodman
 
MCFX Marketing Plan with Facebook Affiliate
MCFX Marketing Plan with Facebook AffiliateMCFX Marketing Plan with Facebook Affiliate
MCFX Marketing Plan with Facebook AffiliateJeanne Mike
 
Rainbow Industries
Rainbow IndustriesRainbow Industries
Rainbow Industriesxdesigns
 

Viewers also liked (7)

Defeating Windows memory forensics
Defeating Windows memory forensicsDefeating Windows memory forensics
Defeating Windows memory forensics
 
Dnb2 ibi rex (1)
Dnb2 ibi rex (1)Dnb2 ibi rex (1)
Dnb2 ibi rex (1)
 
Enoek Alves Application1
Enoek Alves Application1Enoek Alves Application1
Enoek Alves Application1
 
Prezentacja michał błachnio
Prezentacja michał błachnioPrezentacja michał błachnio
Prezentacja michał błachnio
 
Diane goodman Herdsa 2013 subm
Diane goodman Herdsa 2013 submDiane goodman Herdsa 2013 subm
Diane goodman Herdsa 2013 subm
 
MCFX Marketing Plan with Facebook Affiliate
MCFX Marketing Plan with Facebook AffiliateMCFX Marketing Plan with Facebook Affiliate
MCFX Marketing Plan with Facebook Affiliate
 
Rainbow Industries
Rainbow IndustriesRainbow Industries
Rainbow Industries
 

Similar to C lab manaual

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
DR B.Surendiran .
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
C file
C fileC file
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
Dr.Sandhiya Ravi
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
Arrays
ArraysArrays
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
KavyaSharma65
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
PRATIKSHABHOYAR6
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
Syed Tanveer
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
Mazedurr rahman
 

Similar to C lab manaual (20)

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C file
C fileC file
C file
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Arrays
ArraysArrays
Arrays
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
week-6x
week-6xweek-6x
week-6x
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
Ds
DsDs
Ds
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 

C lab manaual

  • 1. PART- A 1a. WAP to find the area of the triangle #include<stdio.h> #include<conio.h> #include<math.h> void main() { float a,b,c,area,s;//s is semi perometer i.e. s=(a+b+c)/2 clrscr(); printf("enter the three sides of triangle"); scanf("%f%f%f",&a,&b,&c); if((a+b)>c&&(a+c)>b&&(b+c)>a) { s=(a+b+c)/2; area=sqrt(s*(s-a)*(s-b)*(s-c)) ; printf("the area of given triangle is-->%f",area); } else printf("the sides given are invalid...enter vaild sides"); getch(); }
  • 2. Output enter the three sides of triangle 1 1 1 the area of given triangle is-->0.433013 1b. Wap to find the area of the circle #include<stdio.h> #include<conio.h> void main() { float p=3.14,r,area; clrscr(); printf("Enter the value of radious = "); scanf("%f",&r); area=p*r*r; printf("nThe area of circle is = %f",area); getch(); }
  • 3. Output Enter the value of radious = 2 The area of circle is = 12.560000 2. Wap to find the simple interest ,given the principle,time and rate of interest with appropriate validation #include<stdio.h> #include<conio.h> void main() { int p,t; float r,si; clrscr(); printf("n enter principle,rate and time"); scanf("%d%f%d",&p,&r,&t); si=(p*r*t)/100; printf("n simple interest:%f",si); getch(); } Output Enter the year which you know to check that it is leap year or not:->2008 The given year is leap year
  • 4. 3. WAP to check whether the given year is leap year or not #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("n Enter the year which you know to check that it is leap year or not:->"); scanf("%d",&n); if((n%400==0)||(n%4==0)&&(n%100!=0)) { printf("n The given year is leap year"); } else { printf("n The given year is not a leap year"); } getch(); }
  • 5. 4. WAP to find the root of the quadratic equation with appropriate message. //roots of the quadratic equation #include<stdio.h> #include<conio.h> #include<math.h> void main() { int a,b,c,d=0,rp,ip; float x1,x2,e; clrscr(); printf("n enter the coefficient of a,b and c"); scanf("%d%d%d",&a,&b,&c); if(a>0) { d=b*b-4*a*c; if(d==0) { printf("n roots are equal"); x1=x2=-b/(2*a); printf("n root 1=%f",x1); printf("n root 2=%f",x2);
  • 6. } else if(d>0) { e=sqrt(d); printf("n roots are real"); x1=-(b+e)/(2*a); x2=-(b+e)/(2*a); printf("n root 1=%f",x1); printf("n root 2=%f",x2); } else { printf("root are imaginary"); } } else { printf("n this is not a quadratic equation"); } getch(); }
  • 7. 6. WAP to find GCD and LCM of given two numbers #include<stdio.h> #include<conio.h> void main() { int u,v,temp,a,b,lcm,gcd; clrscr(); printf("n enter two number"); scanf("%d%d",&u,&v); a=u; b=v; while(v!=0) { temp=u%v; u=v; v=temp; } gcd=u; lcm=(a*b)/gcd; printf("n GCD of two number=%d",gcd); printf("n LCM of the two number=%d",lcm); getch(); }
  • 8. 7. WAP to calculate sin(x) series. #include<stdio.h> #include<conio.h> void main() { int n,sign=1,i; float x,t,sum; clrscr(); printf("n enter value of x and n"); scanf("%f%d",&x,&n); x=(3.14 /180)*x; sum=t=x; for(i=1;i<n;i++) { sign=-1; t=sign*t*x*x/(2*i*(2*i+1)); sum=sum+t; } printf("sum of sin x series=%f",sum); getch(); }
  • 9. 8. WAP to print all prime numbers between m and n #include<stdio.h> #include<conio.h> void main() { int m,n,i,j,prime=0; clrscr(); printf("n enter two number from which you want to check prime number"); scanf("%d%d",&m,&n); if(m<2) m=2; for(i=m;i<=n;i++) { prime=1; for(j=2;j<=i-1;j++) if (i%j==0) { prime=0; break; } if(prime) printf("n %dt",i);
  • 10. } getch(); } 9. WAp to reverse a number and check whether it is palindrome or not #include<stdio.h> #include<conio.h> void main() { int n,d,r=0,u=0; clrscr(); printf("n enter a number"); scanf("%d",&n); u=n; while(n!=0) { d=n%10; r=(r*10)+d; n=n/10; } if (r==u) printf("n number is palindrome"); else printf("n number is not palindrome"); getch();
  • 11. } 10 WAP to generate and print first n Fibonacci numbers using function. #include<stdio.h> #include<conio.h> void fibo(int); void main() { int n; clrscr(); printf("n enter the limit of the seriesn"); scanf("%d",&n); fibo(n); getch(); } void fibo(int n) { int a=0,b=1,c,i=3; printf("n fibonacci series=n"); if(n<1) printf("enter the valid limit"); else if(n==1) printf("0"); else if(n==2) printf("%dt%d",a,b);
  • 12. else { printf("0 t 1"); while(i<=n) { c=a+b; printf("t%d",c); a=b; b=c; i++; } } } 11 WAP to find factorial of a given number usind recursive function. #include<stdio.h> #include<conio.h> int factorial(); void main() { int n; clrscr(); printf("n enter a numbern"); scanf("%d",&n); printf("n factorial=%d",factorial(n)); getch(); }
  • 13. int factorial(int n) { if(n==0) { return(1); } else { return(n*factorial(n-1)); } } 12 WAP to convert upper case alphabets to lower case alphabets in the given string and vice versa. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[20]; int i; clrscr(); puts("enter a stringn"); gets(str); printf("n original string=%s",str); for(i=0;str[i]!='0';i++) {
  • 14. if(str[i]>='A' && str[i]<='Z') { str[i]=str[i]+32; } else if(str[i]>='a' && str[i]<='z') { str[i]=str[i]-32; } } printf("n change string is:%s",str); getch(); } 13 write a program to read two strings and concatenate them (without using library function). #include<stdio.h> #include<conio.h> #include<string.h> void main() { char str1[20],str2[10]; int i=0,j=0; clrscr(); puts("enter string first");
  • 15. gets(str1); puts("n enter string second"); gets(str2); while(str1[i]!='0') { str1[i++]; } while(str2[j]!='0') { str1[i]=str2[j]; str1[i++]; str2[j++]; str1[i]='0'; } printf("concaneted string="); puts(str1); getch(); } 14 WAP to read a sentence and count the number of vovel and consonant. PART -B 1. WAP to read N integer (zero,+ve and -ve) into an arrey and find the sum of positive numbers, sum of negative numbers and average of all input numbers #include<stdio.h>
  • 16. #include<conio.h> void main() { int a[20],n,i,sum1=0,sum2=0; float avg=0.0; clrscr(); printf("n enter the size of the arrayn"); scanf("%d",&n); printf("enter array element 1 by 1 n "); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) { if(a[i]>0) sum1=sum1+a[i]; else sum2=sum2+a[i]; } avg=(sum1+sum2)/n; printf("n sum of posotive number=%d",sum1); printf("n sum of negative number =%d",sum2); printf("n average on entered number =%f",avg); getch(); }
  • 17. 2. WAP to input N real numbers and to find the mean , variance and standard deviation #include<stdio.h> #include<conio.h> #include<math.h> void main() { float a[20],sum=0.0,mean=0.0,var,sumsqr,dev; int n,i; clrscr(); printf("n enter the size of the arrayn"); scanf("%d",&n); printf("enter array element 1 by 1 n "); for(i=0;i<n;i++) { scanf("%f",&a[i]); sum=sum+a[i]; } mean=sum/n; for(i=0;i<n;i++) sumsqr=sumsqr+((a[i]-mean)*(a[i]-mean)); var=sumsqr/n; dev=sqrt(var); printf("n mean of entered number =%f",mean); printf("n variatiuon=%f",var);
  • 18. printf("n deviation=%f",dev); getch(); } 3. WAP to input N numbers and store them in an array and apply linear search #include<stdio.h> #include<conio.h> void main() { int a[20],item,i,flag=0; int n; clrscr(); printf("n enter size of the arrayn"); scanf("%d",&n); printf("n enter array element 1 by 1 n"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("n enter a searching numbern"); scanf("%d",&item); for(i=0;i<n;i++) if(item==a[i]) { flag=1; break;
  • 19. } if(flag) printf("n searching number %d is found at %d position",item,i+1); else printf("n searching value not found"); getch(); } 4. WAP to sort N numbers is ascending order or descending order using bubble sort #include<stdio.h> #include<conio.h> void main() { int a[10],i,j,n,temp; clrscr(); printf("n enter the size of the arrayn"); scanf("%d",&n); printf("n enter the array element 1 by 1 n"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("n after insertion array is n"); for(i=0;i<n;i++)
  • 20. printf("%dt",a[i]); for(i=0;i<n-1;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 after sorting in ascending order array isn"); for(i=0;i<n;i++) printf("%dt",a[i]); getch(); } 5. WAP to implement binary search //binary searching #include<stdio.h> #include<conio.h> void main() { int a[10],i,j,n,temp,item,ub,lb,mid,found=0; clrscr(); printf("n enter the size of the arrayn"); scanf("%d",&n);
  • 21. printf("n enter the array element 1 by 1 in ascending ordern"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("n after insertion array is n"); for(i=0;i<n;i++) printf("%dt",a[i]); for(i=0;i<n-1;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 enter a searching numbern"); scanf("%d",&item); lb=0; ub=n-1; while(lb<ub) { mid=(lb+ub)/2; if(item==a[mid]) { found=1; break;
  • 22. } if(item<a[mid]) ub=mid-1; else lb=mid+1; } if(found) printf("n searching value is found at %d position",mid+1); else printf("n searching value not found"); getch(); } 6. WAP to read two matrices A & B of size M*N and perform product of two given matrices. #include<stdio.h> #include<conio.h> int main() { int a[' '][' '],b[' '][' '],c[' '][' '],i,j,k,m1,n1,m2,n2; clrscr(); printf("n enter the order of the first matrix"); scanf("%d%d",&m1,&n1); printf("n enter the order of the second matrix"); scanf("%d%d",&m2,&n2); if(m1!=n2) { printf("multiplication not possible"); getch(); return 0; } printf("n enter matrix 1 element 1 by 1");
  • 23. for(i=0;i<m1;i++) { for(j=0;j<n1;j++) { scanf("%d",&a[i][j]); } } printf("n enter matrix 2 element 1 by 1"); for(i=0;i<m2;i++) { for(j=0;j<n2;j++) { scanf("%d",&b[i][j]); } } printf("n matrix 1 isn"); for(i=0;i<m1;i++) { for(j=0;j<n1;j++) printf("%dt",a[i][j]); printf("n"); } printf("n matrix 2 is n"); for(i=0;i<m2;i++) { for(j=0;j<n2;j++) printf("%dt",b[i][j]); printf("n"); } // multiplication start for(i=0;i<m1;i++) { for(j=0;j<n1;j++) { c[i][j]=0; for(k=0;k<m1;k++) c[i][j]=c[i][j]+a[i][k]*b[k][j]; } } printf("n after multip[lication matrix 3 is n"); for(i=0;i<m1;i++) {
  • 24. for(j=0;j<n2;j++) printf("%dt",c[i][j]); printf("n"); } getch(); return 0; } 7. WAP to list the name of the students who have scored more than 60% of total marks in three subject using str var #include<Stdio.h> #include<conio.h> struct student { int usn; char name[10]; int marks[3]; int total; }; struct student s[5]; void main() { int i,j,n; clrscr(); printf("n enter the number of the studentn"); scanf("%d",&n); for(i=0;i<n;i++) {
  • 25. printf("n enter the details of %d studentn",i+1); printf("enter student usnn"); scanf(" %d",&s[i].usn); printf("n enter student namen"); scanf("%s",&s[i].name); printf("n enter three paper marks 1 by 1 n"); for(j=0;j<3;j++) { scanf("%d",&s[i].marks[j]); s[i].total=s[i].total+s[i].marks[j]; } } clrscr(); printf("n n student details (scored more than 60%)....."); printf("n .........."); for(i=0;i<n;i++) { if(s[i].total>=180) { printf("n usn no.=%d",s[i].usn); printf("n student name=%s",s[i].name); printf("n total marks=%d",s[i].total); } printf("nnn"); }
  • 26. getch(); } 8 WAP to compute the sum of two complex number-passing a structure to a function. #include<stdio.h> #include<conio.h> struct complex { int real,imag; }; typedef struct complex s; void main() { s x,y; clrscr(); printf("n enter the first complex number"); printf("n enter real part="); scanf("%d",&x.real); printf("n enter the imaginary part="); scanf("%d",&x.imag); printf("n enterthe second imaginary part"); printf("n enter real part="); scanf("%d",&y.real); printf("n enter imaginary part="); scanf("%d",&y.imag);
  • 27. printf("n addition of two complex number is=(%d+i%d)+(%d+i%d)=(%d+i%d)",x.real,x.imag,y.real,y.imag,x.real+y.real,x.imag+y.imag); getch(); } 9. Define a book structure having book info . WAP to accept date and list out all the book infopublished during date. #include<stdio.h> #include<conio.h> struct date { int month; int year; }; typedef struct date pdate; struct book { int isbn; char title[20]; char author[20]; int price; pdate date; }; typedef struct book books; void main() { pdate search;
  • 28. books mca[20]; int n,i; clrscr(); printf("n enter how many xbookst"); scanf("%d",&n); for(i=0;i<n;i++) { printf("n enter the details of %d books n",i+1); printf("n enter the isbn number t"); scanf("%d",&mca[i].isbn); printf("n enter the name of the bookt"); scanf("%s",mca[i].title); printf("n enter the author namet"); scanf("%s",mca[i].author); printf("n enter the price of the bookt"); scanf("%d",&mca[i].price); printf("n enter the mounth of the publicationt"); scanf("%d",&mca[i].date.month); printf("n enter the year of the publicationt"); scanf("%d",&mca[i].date.year); } printf("n enter the month of publication that to searcht"); scanf("%d",&search.month); printf("n enter the year of publication to searcht"); scanf("%d", &search.year);
  • 29. printf("nn book datails.....n"); for(i=0;i<n;i++) { if((mca[i].date.month==search.month)&&(mca[i].date.year==search.year)) { printf("n title=%s",mca[i].title); printf("n isbn=%d",mca[i].isbn); printf("n author name=%s",mca[i].author); printf("n price of the book=%d",mca[i].price); printf("n month of publication=%d",mca[i].date.month); printf("n year of publication=%d",mca[i].date.year); } } getch(); } 10. define structure having students info with 5 sub marks using array, list out all the failed students. #include<stdio.h> #include<conio.h> struct student { char name[20]; int usn,tot,sub[5]; }; void main()
  • 30. { int i,n,j; struct student std[10]; clrscr(); printf("n enter the number of the student t"); scanf("%d",&n); printf("n enter the student details.."); for(i=0;i<n;i++) { std[i].tot=0; printf("n enter name of the %d student=t",i+1); scanf("%s",std[i].name); printf("n enter usn of the %d student=t",i+1); scanf("%d",&std[i].usn); printf("n enter marks of the %d student==t",i+1); for(j=0;j<5;j++) { printf("n enter subject %d markst",j+1); scanf("%d",&std[i].sub[j]); while(std[i].sub[j]>100) { printf("marks over flow n reemter the markst"); scanf("%d",&std[i].sub[j]); } std[i].tot+=std[i].sub[j];
  • 31. } } printf("n list of failed studentsn"); for(i=0;i<n;i++) { if(std[i].tot<200) { printf("n name=%st",std[i].name); printf("n usn=%dt",std[i].usn); printf("n total=%d",std[i].tot); } } getch(); } 11. WAP to find the sum of n integers in an array using pointers. #include<stdio.h> #include<conio.h> void main() { int n,arr[10],i,*p,sum=0; p=arr; clrscr(); printf("n enter the size of the arrayn"); scanf("%d",&n); printf("n enter %d numbern",n);
  • 32. for(i=0;i<n;i++) { scanf("%d",&arr[i]); } for(i=1;i<=n;i++) { sum=sum+*p; *p++; } printf("n sum of all the number =%d",sum); getch(); } 12. WAP to read and write to a file. #include<stdio.h> #include<conio.h> FILE *fp; void main() { char name[20]; int usn,marks,n,i; clrscr(); fp=fopen("student.dat","w"); printf("n how many student records you want to enter t"); scanf("%d",&n); for(i=1;i<=n;i++)
  • 33. { printf("n enter %d student name t",i); scanf("%s",&name); printf("n enter %d student usn t",i); scanf("%d",&usn); printf("n enter %d student marks t",i); scanf("%d",&marks); fprintf(fp,"%st%dt%dn",name,usn,marks); } fclose(fp); fp=fopen("student.dat","r"); printf("students records are n"); for(i=1;i<=n;i++) { fscanf(fp,"%s%d%d",&name,&usn,&marks); printf("nnn name of %d student=%s",i,name); printf("n usn of %d student=%d",i,usn); printf("n marks of %d student=%d",i,marks); } fclose(fp); getch(); } 13. wap to creat and count number of character in a file. #include<stdio.h> void main()
  • 34. { FILE *f; char fname[20],c; int ctr=0; clrscr(); f=fopen("rj","w"); fclose(f); printf("n enter the file name to openn"); scanf("%s",fname); f=fopen("fname","r"); if (!f) printf("n file not exist..permission denied"); else { c=getc(f); for(;getc(f)!=EOF;ctr++) { } printf("n total count of character is %d",ctr); } getch(); }
  • 35. 14. WAP to handle file with mixed data type. #include<stdio.h> struct emp { char name[20]; int empno; float sal; char status[10]; }; void main() { typedef struct emp s; s s1; FILE *f; clrscr(); f=fopen("deepak.txt","w"); /* if(!f) puts("file not exist.permission denied"); else { */ printf("...employee details......n"); printf("n enter the employee name="); scanf("%s",s1.name); //fflush(stdin); printf("n enter the employee number ="); scanf("%d",&s1.empno);
  • 36. printf("n enter employee salary="); scanf("%f",&s1.sal); // fflush(stdin); printf("n enter the employee status="); scanf("%s",s1.status); // fprintf(f,"%s%d%f%c",s1.name,s1.empno,s1.sal,s1.status); fclose(f); f=fopen("deepak.txt","r"); // fscanf(f,"%s%d%f%c",s1.name,&s1.empno,&s1.sal,s1.status); printf("n name=%s",s1.name); printf("n emp number =%d",s1.empno); printf("n employee salary=%f",s1.sal); printf("n employee status=%s",s1.status); fclose(f); getch(); }