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 

Friday, April 23, 2021

PPSUC LAB EXAM SAMPLE QUESTIONS

 1)a)Write a C program to convert a string to a long integer

  b)Write a program in C which is a Menu-Driven Program to compute the area of the various geometrical shape


2)a)Write a program in C to swap numbers using call by reference.

  b)Write a program in C to sort elements of array in ascending order.


3)a) Write a C program to demonstrate the Nested Structures

  b) Write a Program to demonstrate the use of pointer to pointer variable.


4)a)Write a C program to demonstrate the array of structures

  b)Write a program to find the factorial of the given number using recursive function call


5)a)Write a C program to compute the perimeter and area of a rectangle with a height of 7 Inches and width of 5 inches

  b)Write a C program to check whether a given number is an Armstrong number or not.


6)a)Write a C program that accepts 4 integers p, q, r, s from the user where r and s are positive and p is even. If q is greater than r and s is greater than p and if the sum of r and s is greater than the sum of p and q print "Correct values", otherwise print "Wrong values".

  b)Write a program in C to find transpose of a given matrix


7)a) Write a C Program to print contents of file

  b) Write a C program to add two matrix of the size 2X2.


8)a) Write a C program to check whether a given number is an Armstrong number or not.

  b) Write a program in C to swap numbers using call by reference.


9)a) Write a program in C to add two numbers using pointers.

  b) Write a program to read & display the student data using structure


10)a)Write a C program to write some text to a text file

   b)Write a program to read & display the student data using UNION


PPSUC LAB RECORD PROGRAMS

 1) CLICK HERE_LIST-1

 2)CLICK HERE_LIST-2

Monday, January 18, 2021

PROGRAMMING FOR PROBLEM SOLVING USING C_R20_SYLLABUS

"" R-20 Syllabus for CSE, JNTUK w. e. f. 2020 – 21""

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

Course Objectives: 
The objectives of Programming for Problem Solving Using C are 
 To learn about the computer systems, computing environments, developing of a computer program and Structure of a C Program 
 To gain knowledge of the operators, selection, control statements and repetition in C 
 To learn about the design concepts of arrays, strings, enumerated structure and union types and their usage. 
 To assimilate about pointers, dynamic memory allocation and know the significance of Preprocessor. 
 To assimilate about File I/O and significance of functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UNIT I 
Introduction to Computers: Creating and running Programs, Computer Numbering System, Storing Integers, Storing Real Numbers Introduction to the C Language: Background, C Programs, Identifiers, Types, Variable, Constants, Input/output, Programming Examples, Scope, Storage Classes and Type Qualifiers. Structure of a C Program: Expressions Precedence and Associativity, Side Effects, Evaluating Expressions, Type Conversion Statements, Simple Programs, Command Line Arguments. 

UNIT II 
Bitwise Operators: Exact Size Integer Types, Logical Bitwise Operators, Shift Operators. Selection & Making Decisions: Logical Data and Operators, Two Way Selection, Multiway Selection, More Standard Functions. Repetition: Concept of Loop, Pretest and Post-test Loops, Initialization and Updating, Event and Counter Controlled Loops, Loops in C, Other Statements Related to Looping, Looping Applications, Programming Examples. 

UNIT III 
Arrays: Concepts, Using Array in C, Array Application, Two Dimensional Arrays, Multidimensional Arrays, Programming Example – Calculate Averages Strings: String Concepts, C String, String Input / Output Functions, Arrays of Strings, String Manipulation Functions String/ Data Conversion, A Programming Example – Morse Code Enumerated, Structure, and Union: The Type Definition (Type def), Enumerated Types, Structure, Unions, and Programming Application. 

UNIT IV 
Pointers: Introduction, Pointers to pointers, Compatibility, L value and R value Pointer Applications: Arrays, and Pointers, Pointer Arithmetic and Arrays, Memory Allocation Function, Array of Pointers, Programming Application. Processor Commands: Processor Commands. 

UNIT V 
Functions: Designing, Structured Programs, Function in C, User Defined Functions, Inter-Function Communication, Standard Functions, Passing Array to Functions, Passing Pointers to Functions, Recursion Text Input / Output: Files, Streams, Standard Library Input / Output Functions, Formatting Input / Output Functions, Character Input / Output Functions Binary Input / Output: Text versus Binary Streams, Standard Library, Functions for Files, Converting File Type.

Text Books: 
1) Programming for Problem Solving, Behrouz A. Forouzan, Richard F.Gilberg, CENGAGE. 
2) The C Programming Language, Brian W.Kernighan, Dennis M. Ritchie, 2e, Pearson. 

Reference Books: 
1) Computer Fundamentals and Programming, Sumithabha Das, Mc Graw Hill. 
2) Programming in C, Ashok N. Kamthane, Amit Kamthane, Pearson. 
3) Computer Fundamentals and Programming in C, Pradip Dey, Manas Ghosh, OXFORD.