Saturday, July 24, 2021

IMP Questions:

 

1)    Define Structure and write a program to read and display 3 employee records with structure                                                                                        

2)   Define Pointer; briefly explain about the pointer to pointer and pointer Arithmetic operations.                                                                                       

3)   Briefly explain about the different types of File handling functions with examples

Numbers series and their sum

N terms of Natural numbers series and their sum ( 1^2+2^2 + 3^2+4^2+5^2 + 6^2 ..... n^2)

--------------------------------------------------------------------------------------------------- 

#include <stdio.h>

int main()

{

   int i,n,sum=0;

   printf("Input the number of terms in the series: \n");

   scanf("%d",&n);

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

   {

      sum+=(i)*(i);  //main logic series generation

   }

   printf("\nSum of Series upto %d terms : %d \n",n,sum);

  return 0;

}


------------------------------------------------------------------------------------------------

N terms of even numbers series and their sum ( 2^2 + 4^2 + 6^2 ..... n^2)

--------------------------------------------------------------------------------------------------- 

#include <stdio.h>

int main()

{

   int i,n,sum=0;

   printf("Input the number of terms in the series: \n");

   scanf("%d",&n);

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

   {

      sum+=(2i)*(2i);  //main logic even no's generation

   }

   printf("\nSum of Series upto %d terms : %d \n",n,sum);

  return 0;

}

--------------------------------------------------------------------------------------------------

N terms of odd numbers series and their sum ( 1^2 + 3^2 + 5^2+7^2 ..... n^2)

-----------------------------------------------------------------------------------------------

#include <stdio.h>

int main()

{

   int i,n,sum=0;

   printf("Input the number of terms in the series: \n");

   scanf("%d",&n);

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

   {

      sum+=(2i-1)*(2i-1);  //main logic odd number generation

   }

   printf("\nSum of Series upto %d terms : %d \n",n,sum);

  return 0;

}

Triangle Display

 ^^^^^ Number Triangle Display ^^^^^

1

1    2

1    2    3

1    2    3    4

1    2    3    4    5

---------------------------------------------------------------------------------

#include<stdio.h>

void main()

{

 int i,j;

 printf("Triangle Display \n");

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

 {

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

   {   

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

   }

  printf("\n");

 }

}

*************************************************

1    2    3    4    5    6

1    2    3    4    5

1    2    3    4

1    2    3

1    2

1

**************************************************

#include<stdio.h>

void main()

{

 int n,i,j;

 clrscr();

 printf("Enter the no of lines required: \n");

 scanf("%d",&n);

 for(i=n;i>0;i--)

 {

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

   {

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

   }

    printf("\n");

 }

}

Star Triangle Program

^^^^^^^^^^^^^Triangle Display^^^^^^^^^^^^^^^

*

*    *

*    *    *

*    *    *    *

*    *    *    *    *

---------------------------------------------------------------------------------

#include<stdio.h>

void main()

{

 int i,j;

 printf("Triangle Display \n");

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

 {

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

   {   

      printf("*\t");

   }

  printf("\n");

 }

}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

*    *    *    *    *

*    *    *    *

*    *    *

*    *

*

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#include<stdio.h>

void main()

{

 int n,i,j;

 clrscr();

 printf("Enter the no of lines required: \n");

 scanf("%d",&n);

 for(i=n;i>0;i--)

 {

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

   {

     printf("* \t");

   }

    printf("\n");

 }

}

Friday, July 23, 2021

To display the n terms of harmonic series and their sum. 1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms.

 #include <stdio.h>

int main()

{

   int i,num1;

   float num2=0;

   printf("Input the number of terms in the series: \n");

   scanf("%d",&num1);

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

   {

       if(i<=num1)      

      {

              printf("1/%d + ",i);

              num2+=1/(float)i;

       }

   }

        printf("\nSum of Series upto %d terms : %f \n",num1,num2);

  return 0;

}

OUTPUT:

Input the number of terms in the series:

5

1/1 + 1/2 + 1/3 + 1/4 + 1/5

Sum of Series upto 5 terms : 2.283334

Input the number of terms in the series:

10

1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10

Sum of Series upto 10 terms : 2.928968


Armstrong number

Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

Let's try to understand why 153 is an Armstrong number.

153 = (1*1*1)+(5*5*5)+(3*3*3)

where:

(1*1*1)=1

(5*5*5)=125

(3*3*3)=27

1+125+27=153 it is an Armstrong number

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#include<stdio.h>

int main()

{

int n,r,sum=0,temp;

printf("enter the number=");

scanf("%d",&n);

temp=n;

while(n>0)

{

    r=n%10;

    sum=sum+(r*r*r);

    n=n/10;

}

if(temp==sum)

    printf("armstrong number ");

else

    printf("Given number is not a armstrong number");

return 0;

}

OUTPUT:

enter the number=371

armstrong number

enter the number=45

Given number is not a armstrong number



To find transpose of a given matrix

 #include<stdio.h>

int main()

{

    int mat[10][10];

    int i,j,r,c;

    printf("Enter number of Rows :");

    scanf("%d",&r);

    printf("Enter number of Cols :");

    scanf("%d",&c);

/*-------------------------------------------------------------------------*/

    printf("\nEnter matrix elements :\n");

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

    {

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

        {

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

        }

    }

/*-------------------------------------------------------------------------*/

    /*Transpose a matrix */

    printf("\nTranspose Matrix is : \n");

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

    {

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

        {

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

        }

        printf("\n");        

    }

    return 0;      

}

-------------------------------------------------------------

OUTPUT1:

Enter number of Rows :2

Enter number of Cols :2


Enter matrix elements :

1

2

3

4

Transpose Matrix is :

1   2           1    3   

3   4  ==>  2    4   


Multiplication of two square Matrices

To multiply an m×n matrix by an n×q matrix, the n's must be the same, and the result is an m×q matrix.
m×n n×q = m×q
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Write a program in C for multiplication of two square Matrices.
#include<stdio.h>
int main()
{
    int a[10][10],b[10][10],result[10][10];
    int i,j,r1,c1,r2,c2;
    int sum,k;

    
    printf("Enter number of Rows of matrix a: ");
    scanf("%d",&r1);
    printf("Enter number of Cols of matrix a: ");
    scanf("%d",&c1);

    printf("Enter number of Rows of matrix b: ");
    scanf("%d",&r2);
    printf("Enter number of Cols of matrix b: ");
    scanf("%d",&c2);   

    /*Testing the multiplication rule of two matrix*/   

    if(c1==r2) //col1 and row2 comparision
    {   //if conditon begin

/*---------------------------------------------------*/
    printf("\n Enter elements of matrix a: \n");
   
    for(i=0;i< r1;i++) //row times repeation
    {
        for(j=0;j< c1;j++) //col times repeation        
      {
               scanf("%d",&a[i][j]);
        }
    }
/*---------------------------------------------------*/

    printf("\nEnter elements of matrix b: \n");
   
    for(i=0;i< r2;i++) //row times repeation
    {
        for(j=0;j< c2;j++) //col times repeation  
      {
            scanf("%d",&b[i][j]);
        }
    }
/*---------------------------------------------------*/
              /*Multiplication of two matrices*/
        for(i=0;i<r1;i++)
        {
            for(j=0;j< c2;j++)
            {
                sum=0;
                for(k=0;k<c1;k++)
                {
                    sum=sum + (a[i][k]*b[k][j]);
                }
                result[i][j]=sum;
            }
        }
/*---------------------------------------------------*/
       /* Multiplication output*/
       for(i=0;i< r1;i++)
       {
          for(j=0;j< c2;j++)
          {
            printf("result of multiplication is [%d,%d] : ",i,j);
            printf("%d\n",result[i][j]);
          }
       }   

    
   }   //if condition close
/*---------------------------------------------------*/

    else
    {
        printf("\nMultiplication can not be done.");
    }
   
 
    return 0;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OUTPUT
Enter number of Rows of matrix a: 2
Enter number of Cols of matrix a: 2
Enter number of Rows of matrix b: 2
Enter number of Cols of matrix b: 2

Enter elements of matrix a:
1
2
3
4

Enter elements of matrix b:
1
2
3
4
result of multiplication is [0,0] : 7
result of multiplication is [0,1] : 10
result of multiplication is [1,0] : 15
result of multiplication is [1,1] : 22

Thursday, July 15, 2021

PPSUC UNITWISE QUESTIONS

UNIT-1

1)   Convert the given Decimal number (125)10  into Binary, Octal, Hexa decimal number system  

2)  Convert the given Binary number (101011)2  into Decimal, Octal, Hexa decimal number system  

3)  Convert the given Octal number (31)8  into Binary, Decimal, Hexa decimal number system  

4)  Convert the given Hexadecimal  number (19)16  into Decimal, Octal, Binary number system  

5)  Briefly explain the different types of data types

6)  Briefly explain the differences between the variable and constant with a sample programs

7)  Briefly explain different types of Storage Classes

8)  What is local scope and global scope explain with a program.

9)  What is an Expressions, and explain the  Precedence and Associativity rules with some examples

10) What is the need of Type Conversion Statements explain with examples programs

11) What is Command Line Arguments and write a program to add two numbers using command line arguments.

12)Briefly explain about the Type Qualifiers with a programming example.

UNIT-2

1)   Briefly explain the different types of operators with examples.

2)  What are the Bitwise operators explain with examples.

3)  Briefly different types of Conditional statements with sample programs

4)  Write a Program to demonstrate the calculator with Switch Case.

5)  Briefly explain about the Pre-test loop and Post-test loops with a sample program to find the given number is Palindrome or not

6)  Demonstrate the Nested conditional statements with a program

7)  Demonstrate the Nested looping statements with a program.

8)  Briefly explain the unconditional statements Break, Continue, goto

9)  Demonstrate the shift operators with program

10)Demonstrate the use of Switch case with a program.

UNIT-3

1)   Briefly explain different types of arrays and write a program to perform the addition of two matrices.

2)  Define string and briefly explain the different types of string manipulation functions with examples

3)  What is Enum, explain with a program.

4)  Define Type def, explain with a program.

5)  Define Structure and write program to read 3 students records and display with structures.

6)  Define Union and write program to read 3 students records and display with structures.

7)  Briefly explain about the Nested structures with a program

8)  Demonstrate the Array of Structures.

9)  Briefly explain about the differences between the Structures and Unions

10)Write a C program to demonstrate the Employee data using Unions.

11) 1.Briefly explain the following with a sample program

A) Enumeration

B) Structure

C) Union

D) Typedef

 

UNIT-4

1)   Define Pointer and write a program to demonstrate the use of a pointer variable.

2)  Briefly explain different types Dynamic Memory Allocation functions.

3)  Define pointer to pointer with program

4)  What is pointer compatibility  explain with an example

5)  What is L-values, R-value demonstrate with example.

6)  Demonstrate Array of pointer with a program

7)  What is pointer to array explain with a program.

8)  Define different types Processor Commands with examples

9)  What is Macro explain with a sample program.

10)What is pointer arithmetic operation explain with example.

UNIT-5

1)   Briefly explain different type’s functions with examples and Write a program to swap two numbers with call by reference.

2)  Briefly explain about function call by values with a program.

3)  What is inter function communication, explain with examples.

4)  Demonstrate Passing Array to Functions with a program.

5)  Demonstrate Passing Pointers to Functions with a program.

6)  Briefly explain different types of File handling functions in C

7)  What do you mean by Recursion? Write a program to find factorial of given

number using recursion.

8)  Differentiate between user defined functions and pre-defined functions. Also

explain the purpose of function prototype.

9)  Write a C program to copy the contents of one file to another file.

10)Write a C program to merge two files into a single file

PPSUC 5 UNITS NOTES

CLICK HERE 

PPSUC OLD QUESTION PAPERS

CLICK HERE