Programs as per Practical syllabus list

1)  Write a program in c to find area of circle (area of circle = Pi * r2).

 // program to find area of circle

 #include <stdio.h>

#include <conio.h>

 void main()

{

               int r;

               float Pi=3.14,area;

              clrscr();

               printf ("\nEnter a radius of circle :  ");

               scanf ("%d", &r);

 

               area = Pi * r * r;

 

               printf ("\nResult of program to find area of circle \n\n");

               printf ("area of circle =  %f\n", area);

 

               getch();

}

 

Flowchart:


 

Output:



 

2)  Write a program to find average of 3 numbers and print result.

 /*Prog no-2 program to find average of 3 numbers and print result */

 #include <stdio.h>

#include <conio.h>

 void main()

{

                int a,b,c,sum,avg;

                 clrscr();

                printf("\n\nAccept the 3 numbers from user\n" );

                printf("Enter 3 integer Numbers: ");

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

 

                sum = a + b + c;

                avg = sum/3;

 

                printf ("\n Average of 3 numbers =  %d", avg);

  

                getch();

}

 

Flowchart:

 


 Output:

 


3)     3) Write a Program to find greater/maximum number amongst 2 numbers.

 

/* Prog no-3 Program to find greater/maximum number amongst 2 numbers */

 

#include <stdio.h>

#include <conio.h>

 

void main()

{

                int a,b;

 

                clrscr();

 

                printf("\n\nEnter two numbers : " );

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

 

                if(a>b)

                {

                        printf("\nGreater/Maximum number = %d",a);

                }

                else

                {

                        printf("\nGreater/Maximum number = %d",b);

                }

 

                getch();

}

 

Flowchart:


  Output:

 


 

 

4)     4) Write a Program to find to check enter number is odd or even.

/* Prog no-4 Program to find to check enter number is odd or even */

 

#include <stdio.h>

#include <conio.h>

 void main()

{

                int num,rem;

 

                clrscr();

 

                printf("\nEnter one integer number  ");

                scanf("%d",&num);

 

                rem = num % 2;

                if(rem==0)

                {

                        printf("\n %d is Even number ",num);

                }

                else

                {

                        printf("\n %d is Odd number",num);

                }

 

                getch();

}

Flowchart:

 


 Output:



5)     Write a program to check enter number is +ve, -ve or Zero.

 

/* Prog no-11 Program to check enter number is +ve, -ve or Zero */

 

#include <stdio.h>

#include <conio.h>

void main()

{

                int num;

                clrscr();

                printf("\nEnter one integer number  ");

                scanf("%d",&num);

                if(num>0)

                {

                        printf("\n %d is +ve number ",num);

                }

                else if(num<0)

                {

                        printf("\n %d is -ve number ",num);

                }

                else

                {

                        printf("\n %d is Zero number ",num);

                }

 

                getch();

}

Flowchart:



Output



6)  Write a program in C to print grade of student based on percentage.

 

/* Prog no-6 Program to print grade of student based on percentage */

 

#include <stdio.h>

#include <conio.h>

 

void main()

{

                float per;

 

                clrscr();

 

                printf("\nEnter one percentage of student  ");

                scanf("%f",&per);

 

                if(per>=90)

                {

                        printf("\n\n Student percentage=  %f \nThe Student has A+ Grade ",per);

                }

                else if(per>=80 && per<=89)

                {

                        printf("\n\n Student percentage=  %f \nThe Student has A Grade ",per);

                }

                else if(per>=70 && per<=79)

                {

                        printf("\n\n Student percentage=  %f \nThe Student has B g Grade rad ",per);

                }

                else if(per>=60 && per<=69)

                {

                        printf("\n\n Student percentage=  %f \nThe Student has C Grade ",per);

                }

                else

                {

                        printf("\nStudent percentage=  %f \nThe Student has D Grade ",per);

                }

 

                getch();

}

 

Output:

 


Flowchart:



7)     Write a C program to print weekday based on given number

 

/* Prog no-7   Program to print weekday based on given number */

#include <stdio.h>

#include <conio.h>

 

void main()

{

          int day;

 

          clrscr();

 

          printf("\n\nEnter number of day from 1 to 7 : " );

          scanf("%d",&day);

 

          switch(day)

          {

                  case 1:

                              printf("\n Monday");

                              break;

                  case 2:

                              printf("\n Tuesday");

                              break;

                  case 3:

                              printf("\n Wednesday");

                              break;

                  case 4:

                              printf("\n Thursday");

                              break;

                  case 5:

                              printf("\n Friday");

                              break;

                  case 6:

                              printf("\n Saturday");

                              break;

                  case 7:

                              printf("\n Sunday");

                              break;

                  default:

                              printf("\n Invalid number");

                              break;

      }

 

          getch();

}

 

Output:

 


Flowchart:



8)  Write a Program to check enter character is vowel or not.

/* Prog no-8  Program to check enter character is vowel or not*/

#include <stdio.h>

#include <conio.h>

 void main()

{

                char ch;

                 clrscr();

                 printf("\n\nEnter Character : " );

                scanf("%c",&ch);

                 switch(ch)

                {

                        case 'A':

                                    printf("\n%c is Vowel",ch);

                                    break;

                        case 'E':

                                    printf("\n%c is Vowel",ch);

                                    break;

                        case 'I':

                                    printf("\n%c is Vowel",ch);

                                    break;

                        case 'O':

                                    printf("\n%c is Vowel",ch);

                                    break;

                        case 'U':

                                    printf("\n%c is Vowel",ch);

                                    break;

                        default:

                                    printf("\n%c is not Vowel it’s Consonant",ch);

                                    break;

            }

                 getch();

}

 Output:

 


 Flowchart:



 

9)     Write a Program in C to find factorial of given number.

 

/* Prog no-9 Program to find factorial of given number */

 #include <stdio.h>

#include <conio.h>

 void main()

{

                int i=1, fact=1, num;

                 clrscr();

                 printf("\n\nEnter numbers : " );

                scanf("%d",&num);

                 while(i<=num)

                {

                        fact = fact * i;

                        i++;

                }

                printf("\nFactorial of %d = %d",num,fact);

                getch();

}

 Output:

 


Flowchart:


10)   Write a program in C to find sum of first 10 natural numbers


/* Prog no-10 Program to find sum of first 10 natural numbers */

 #include <stdio.h>

#include <conio.h>

void main()

{

                int i=1, sum=0;

                clrscr();

                while(i<=10)

                {

                        sum = sum + i;

                        i++;

                }

                 printf("\nThe Sum of first 10 natural number = %d",sum);

                getch();

}

 Output:

 Flowchart:



 

11)     Write a C program to find odd numbers up to N.

 

/* Prog no-11 Program to find odd numbers up to n number */

#include <stdio.h>

#include <conio.h>

 void main()

{

                int i=1, N;

                 clrscr();

                printf("\n Odd numbers print up to n number\n Give N number : ");

                scanf("%d",&N);

                 while(i<=N)

                {

                        printf("\t%d",i);

                        i=i+2;

                }

                 getch();

}

Output:

 


 Flowchart:


 

12)     Write a Program to print Fibonacci series up to Nth number.

/* Prog no-12 Program to print Fibonacci series */

#include <stdio.h>

#include <conio.h>

 void main()

{

                int n,num1=0, num2=1, i=1, sum;

              clrscr();

                 printf("\nEnter n th number : ");

                scanf("%d",&n);

                printf("\n Fibonacci series = ");

                 do

                {

                        sum = num1 + num2;

                        printf("\t%d",sum);

                        num1 = num2;

                        num2 = sum;

                        i++;

                 }while(i<=n);

                 getch();

}

Output:

 


 Flowchart:

 


13)     Write a program to print following series

            1

2        3

4   5   6

           

/* Prog no: 13 Program to print following series

            1

            2  3

            4  5  6             */

 

#include <stdio.h>

#include <stdio.h>

void main()

{

   int i, j, rows, num=1;

   printf("Input number of rows : ");

   scanf("%d",&rows);

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

   {

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

            {

               printf("%d ",num);

               num = num + 1;

            }

            printf("\n");

   }

}

 

Output: (* Note: enter Nth value = 3)

 


 Flowchart:

 

14)     Write a Program to print Prime number from 1 to 100.

/* Program to print Prime number from 1 to 100 */

#include <stdio.h>

#include <conio.h>

void main()

{

 

   int i, j;

   clrscr();

   printf("\nPrime numbers\n");

   for(i = 2; i<100; i++)

   {

 

      for(j = 2; j <= (i/j); j++)

 

 

      if(i%j==0)

            break; // if factor found, not prime

      if(j > (i/j))

            printf("%d\t", i);

   }

   getch();

}


Output:



15)     Write a Program in C to find largest number in an array

/* Program to find largest number in an array */

#include <stdio.h>

#include <conio.h>

void main()

{

   int i,a[5],large;

   clrscr();

   printf("\n\n Enter 5 array element\n ");

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

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

   {

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

 

   }

 

   large=0;

 

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

   {

            if(a[i]>large)

            {

                        large=a[i];

            }

   }

 

   printf("\nlarge number = %d",large);

   getch();

}

 Flowchart:



Output:


16) Write a C program to sort an array element in ascending order.

/* Program No:16 program to sort an array element in ascending order */

#include <stdio.h>

#include <conio.h>

void main()

{

   int a[5],i,j,temp;

   clrscr();

   printf("\n\nEnter 5 array element\n ");


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

   {

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


   }

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

   {

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

{

if(a[i]<a[j])

{

temp = a[i];

a[i] = a[j];

a[j] = temp;

}

}


   }

   printf("\nArray elemente in Accending order\n");

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

   {

printf("\n%d ",a[i]);

   }

   getch();

}

Output: 




17) Write a program in C to find sum of two Matrix.

/* Program to find sum of two Matrix */

#include <stdio.h>

#include <conio.h>

void main()

{

   int i,j,mat1[2][2],mat2[2][2],sum[2][2];

   clrscr();

   printf("\n\nType 4 element for first matrix mat1 = ");

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

   {

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

    {

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

    }

   }

    printf("\n\nType 4 element for first matrix mat2 = ");

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

   {

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

    {

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

    }

   }

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

   {

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

    {

sum[i][j]=mat1[i][j]+mat2[i][j];

    }

   }

 printf("\n\nFirst of 2 x 2 Matrix =  ");

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

   {    

        printf("\n");

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

    {

printf("%d\t",mat1[i][j]);

    }

   }

   printf("\n\nSecond of 2 x 2 Matrix =  ");

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

   { 

   printf("\n");

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

    {

printf("%d\t",mat2[i][j]);

    }

   }

 printf("\n\nSum of 2 x 2 Matrix   =   ");

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

   {    

printf("\n");

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

    {

printf("%d\t",sum[i][j]);

    }

   }

   getch();

}

Output: 



18) Write a program perform transpose (transpose means interchange row in to column and column in to row) matrix.

/* Program No: 18 Program to perform transpose (transpose means interchange row in to column and column in to row) matrix */

#include <stdio.h>

#include <conio.h>

void main()

{

   int i,j,mat[3][3];

   clrscr();

    printf("\n\nPrint 9 element for matrix  = ");

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

   {

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

            {

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

            }

   }

    printf("\nPrint Matrix\n ");

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

   {

            printf("\n");

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

            {

                        printf("%d\t",mat[i][j]);

            }

   }

      printf("\n\n Transpose Matrix(interchange row in to column and column in to row)\n ");

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

   {    printf("\n");

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

            {

                        printf("%d\t",mat[j][i]);

            }

   }

   getch();

}

 Output:



Post a Comment

0 Comments