Saturday, December 28, 2019

PPS LAB PROGRAM QUESTIONS



1. Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches.
2. Write a program to read & display the student data using structure


1. Write a program in C to check whether a number is a prime number or not using the function.
2. 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".


1. Write a program in C which is a Menu-Driven Program to compute the area of the various geometrical shape.
2. Write a C program to calculate the factorial of a given number.


1. Write a program in C to display the n terms of even natural number and their sum.
2. Write a program in C to swap elements using call by reference.


1. Write a program in C to add two numbers using pointers.
2. Write a program in C to find transpose of a given matrix.


1. Write a C program to convert a string to a long integer.
2. Write a program in C for multiplication of two square Matrices.


Friday, December 27, 2019

Algorithm and Flowchart



What is Algorithm?

The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a procedure or a technique.
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results. 

It can be understood by taking an example of cooking a new recipe. To cook a new recipe, one reads the instructions and steps and execute them one by one, in the given sequence. The result thus obtained is the new dish cooked perfectly. Similarly, algorithms help to do a task in programming to get the expected output.

"a logical step-by-step method to solve the problem is called algorithm"

What is Flowchart?


A flowchart is a blueprint that pictorially represents the algorithm and its steps. Flowchart is diagrammatic /Graphical representation of sequence of steps to solve a problem. 

A flowchart is a graphical representation of an algorithm. Programmers often use it as a program-planning tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow of information and processing.

The process of drawing a flowchart for an algorithm is known as “flowcharting”.

To draw a flowchart following standard symbols are use

    Basic flowchart symbols
     

Difference between Algorithm and Flowchart

Algorithm Flowchart
It is a procedure for solving problems. It is a graphic representation of a process.
The process is shown in step-by-step instruction. The process is shown in block-by-block information diagram.
It is complex and difficult to understand. It is intuitive and easy to understand.
It is convenient to debug errors. It is hard to debug errors.
The solution is showcased in natural language. The solution is showcased in pictorial format.
It is somewhat easier to solve complex problem. It is hard to solve complex problem.
It costs more time to create an algorithm. It costs less time to create a flowchart.


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

 1) Algorithm & Flowchart to find the sum of two numbers

Algorithm:
Step-1 Start
Step-2 Input first numbers say A
Step-3 Input second number say B
Step-4 SUM = A + B
Step-5 Display SUM
Step-6 Stop

Flowchart:




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

 2)Algorithm & Flowchart to Print 1 to 20.

Algorithm:
Step 1: Initialize X as 0,
Step 2: Increment X by 1,
Step 3: Print X,
Step 4: If X is less than 20 then go back to step 2.

Flowchart:

Flowchart Algorithm 
 ---------------------------------------------------------------------------------------------------------------------------
3) Algorithm & Flowchart to Determine and Output Whether Number N is Even or Odd

Algorithm:
  • Step 1: Read number N,
  • Step 2: Set remainder as N modulo 2,
  • Step 3: If remainder is equal to 0 then number N is even, else number N is odd,
  • Step 4: Print output.
Flowchart:

 Algorithm Flowchart Example 2

--------------------------------------------------------------------------------------------------------------------------
4) Algorithm & Flowchart to find Area and Perimeter of Rectangle

L : Length of Rectangle
B : Breadth of Rectangle
AREA : Area of Rectangle
PERIMETER : Perimeter of Rectangle

Algorithm:

Step-1 Start
Step-2 Input Side Length & Breadth say L, B
Step-3 Area = L x B
Step-4 PERIMETER = 2 x ( L + B)
Step-5 Display AREA, PERIMETER
Step-6 Stop



















Tuesday, December 17, 2019

Assignment-2

1)Define array and describe two,multi dimensional array  and write a C  

   program to to find out the average of 4 integers using Array’s.

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

   functions, write a program to compare two strings

3)Briefly explain about the Type Definition (Type def) with a program.

4)Define the structure and write a program to demonstrate the array of structure.

5)Describe about the UNION with program.

6)What is a pointer and write a program to swap two numbers with call by reference.

7)Briefly explain about the following
  a)pointer to pointer
  b)array of pointers
  c)pre processor commands.

8)What is dynamic memory allocation and describe different types of dynamic memory allocation functions.

9)Define file and briefly explain bout the different types of file handling functions

10)Write a c program to copy the content of one file to another file.

11)what is inter function communication and describe about the Bi-Directional Communication with a program

12)What is recursion and write a program to demonstrate the recursion.

13)Define the following
  a)passing arrays to the function
  b)passing pointer to the function 
  c)standard functions.

14)Briefly explain about the Enumerated Type with a program.

15)Briefly explain the following
  a)gets and puts
  b)getc and putc
  c)fprintf and fscanf
  d)fread and fwrite
  e)fopen and fclose