0% found this document useful (0 votes)
29 views20 pages

Experiment 01 An 02

This document contains an assessment sheet for an experiment on problem solving techniques. It has 10 items related to algorithm development, flow chart development, pseudo code development, algorithm implementation, experimental results, and viva voce. Each item is worth a certain number of marks and the total marks are out of 100. The sheet contains space for the initials and signature of the evaluating faculty member.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views20 pages

Experiment 01 An 02

This document contains an assessment sheet for an experiment on problem solving techniques. It has 10 items related to algorithm development, flow chart development, pseudo code development, algorithm implementation, experimental results, and viva voce. Each item is worth a certain number of marks and the total marks are out of 100. The sheet contains space for the initials and signature of the evaluating faculty member.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

ASSESSMENT SHEET

INITIALS
Sl. No. EXPERIMENT MARKS OF
FACULTY
Problem Solving Techniques (Algorithm, Pseudocode, Flowcharts).
1.

2. Program using Simple Statements and Expressions.

Scientific Problem Solving using Decision Making and


3.
Looping.

4. Program using Single and Multidimensional Array.

5. Program using String, Math Inbuilt Functions.

Program using User Defined Functions (string & array


6.
manipulation) and StorageClasses.

7. Program using Recursive Function.

8. Program using Dynamic Memory Allocation.

9. Program using Structures and Unions.

10. Program using Files.

TOTAL

AVERAGE

[Type text] KIRTHIKA KM /AP/CSE [Type text]


Ex. No. : 01 Problem Solving Techniques (Algorithm, Pseudo code,
Flowcharts).

Introduction (Problem Solving Techniques)

Computer:

A computer is a device that accepts information (in the form of digitalized data) and manipulates
it for some result based on a program or sequence of instructions on how the data is to be processed.
Complex computers also include the means for storing data (including the program, which is also
a form of data) for some necessary duration. A program may be invariable and built into the
computer (and called logic circuitry as it is on microprocessors) or different programs may be
provided to the computer (loaded into its storage and then started by an administrator or user).
Problem Solving

Computer Programmers are problem solvers. In order to solve a problem on a computer


you must

 Know how to represent the information (data) describing the problem.


 Determine the steps to transform the information from one representation into another.

Problem Solving Techniques

Algorithm:
A process or set of rules to be followed in calculations or other problem-solving operations, especially
by a computer.

Flowchart is a type of diagram that represents an algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This
diagrammatic representation illustrates a solution model to a given problem.
ProgramA computer program is a collection of instructions that performs a specific
task when executed by a computer. A computer requires programs to function, and typically
executes the program's instructions in a central processing unit.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


DRAWING FLOWCHART

Introduction

A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This
diagrammatic representation illustrates a solution model to a given problem.

Guidelines for Drawing flow chart:

1. In drawing a proper flow chart, all necessary requirements should be listed out in logical
order.
2. The flowchart should be clear, neat and easy to follow. There should not be any room for
ambiguity in understanding the flow chart.
3. The usual direction of the flow of a procedure or system is from left to right or top to
bottom.
4. Only one flow line should come out from a process symbol.
5. Only one flow line should enter a decision symbol, but two or three flow lines, one for
each possible answer, should leave the decision symbol.
6. Only one flow line is used in conjunction with terminal symbol.
7. Write within standard flow chart symbols briefly. As necessary, you can use the annotation
symbol to describe data or computational steps more clearly.
8. If the flowchart becomes complex, it is better to use connector symbols to reduce the
number of flow lines. Avoid the intersection of flow lines if you want to make it more
effective and better way of communication.
9. Ensure that the flowchart has a logical start and finish. It is useful to test the validity of
the flowchart by passing through it with a simple test data.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


Flow Chart Symbols

[Type text] KIRTHIKA KM /AP/CSE [Type text]


Bank Teller Flowchart

[Type text] KIRTHIKA KM /AP/CSE [Type text]


Procedure to Draw flow Chart in open office or libre office

Step 1: Start the process.


Step 2: To open Applications, select Office LibreOfficeDraw (OR) OpenOffice.org word
processorFileNewDrawing.
Step 3: To create a new document, select File  New Drawing.

Step 4: To insert flowchart symbols, select tool from the Flowchart toolbar on the
Drawing bar

Step 5: Choose the required flow chart symbol from the Flowchart tool box and Drag a shape in
draw slide.
Step 6: To enter text within the symbols Double-click the shape, and type text OR Click the
Text icon on the Drawing bar, and drag a text object over the shape. Type the text.

Step 8: To group the symbols select the required symbols and right click on it. Choose
Grouping Groupoption. Similarly the symbols can be ungrouped. Step 11:
Stop the process.

Lab Set Questions:


(Students are asked to write down the steps and draw the flow chart to solve the below problems)

SET A:
(Students are asked to write down the Algorithm and pseudo code and create a flow chart to
solve the problems below.)
1. Create a Data Flow Diagram for the Online Car Rental System, which is used by customers
who want to book/rent a car online.
Scenario:
The customer looks up car information in the car database. Following that, the customer selects a
car to rent/borrow. The car is then booked, and the booking details are saved in the book
database. The customer then enters his personal information and credit card information, pays
for the booking, and saves it in the payment database. Following that, the customer receives a
confirmation message as well as a receipt.

2. The procedure begins with a job applicant filling out a form. It goes through several stages,
including managerial approval, posting the job, analyzing and selecting resumes, conducting
interviews, approving candidates, and even sending a welcome e-mail.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


3. Web contains a Forgot Password feature. This page explains the various details of the feature.

A user is asked to enter their e-mail address. If the system finds a unique match, then an email
based on a template is sent to that email address. The email contains a link to the Change Password
page with a token that expires in 15 minutes. If the user opens the email and clicks the link within
15 minutes, then the user is able to reset their password and log in. If there is no email match, then
an error message appears telling the user to contact the association.

4. To log into Facebook account we first enter the facebook URL www.facebook.com in our
browser like Google,Firefox,Safari,Internet Explorer etc. This request is sento the facebook
server and it responds by sending us the home page of facebook.Next we enter the registered
Email id and password and click the login button.Then our login credential is checked .if it is
correct ,we are show our profile.On the other hand ,if the login credential is wrong then an error
occurs and we are prompted to re-enter our Email ID and Password.

5. Create a snake and ladder application. The application should take as input (from the command
line or a file):
 Number of snakes (s) followed by s lines each containing 2 numbers denoting the head and
tail positions of the snake.
 Number of ladders (l) followed by l lines each containing 2 numbers denoting the start and
end positions of the ladder.
 Number of players (p) followed by p lines each containing a name.
After taking these inputs, you should print all the moves in the form of the current player name
followed by a random number between 1 to 6 denoting the die roll and the initial and final position
based on the move.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


MARK
S.NO DESCRIPTION WEIGHTAGE AWARDED

1 Algorithm Development 15

2 Flow Chart Development 15

3 PSEUDO Code Development 15

3 Algorithm Implementation 15

4 Experimental Results 10

6 Viva-voce 30

Total 100

Signature of the Faculty with date

[Type text] KIRTHIKA KM /AP/CSE [Type text]


Ex. No. : 02
Program using Simple Statements and Expressions.

C PROGRAMMING USING SIMPLE CONDITIONAL STATEMENTS


AND EXPRESSIONS

INTRODUCTION:

A statement is a command given to the computer that instructs the computer to take a specific
action, such as display to the screen, or collect input. A computer program is made up of a series
of statements.

STATEMENT AND EXPRESSIONS:

If statement

If statement is a conditional branching statement. In conditional branching statement a


condition is evaluated, if it is evaluate true a group of statement is executed. The simple format
of an if statement is as follows:

SYNTAX:
if (condition)
{
statement;
}

If the expression is evaluated and found to be true, the single statement following the "if"
is executed. If false, the following statement is skipped. Here a compound statement composed of
several statements bounded by braces can replace the single statement.

Here's an example program using simple if statement:

#include<stdio.h>
#include<conio.h>
int main()
{
int number;
clrscr();
printf(“enter the number\n”);
scanf(“%d”,&number); if(number>0)
printf(“given number is positive”);

[Type text] KIRTHIKA KM /AP/CSE [Type text]


getch(); return
0;
}

if else statement:

This feature permits the programmer to write a single comparison, and then execute one of the
two statements depending upon whether the test expression is true or false. The general form of the
if-else statement is

SYNTAX:

if (condition)
{
statement1;
}
else
{
statement2;
}

Here also expression in parentheses must evaluate to (a boolean) true or false. Typically
you're testing something to see if it's true, and then running a code block (one or more
statements) if it is true, and another block of code if it isn't. The statement1 or statement2 can be
either simple or compound statement.

The following program demonstrates a legal if else statement:

#include<stdio.h>
#include<conio.h>
int main()
{
int number;
clrscr();
printf (“enter the number\n”);
scanf(“%d”,&number); if(number>0)
printf(“given number is positive\n”); else
printf(“given number is not positive\n”);
getch();
return 0;
}

[Type text] KIRTHIKA KM /AP/CSE [Type text]


You can set up an if-else statement to test for multiple conditions. The following example uses
two conditions so that if the first test fails, we want to perform a second test before deciding what to
do:

if (x%2==0)
{
printf(“x is an even number”);
}
else
{
if (x>10)
{
printf(“x is an odd number and greater than 10”);
}
else
{
printf(“x is an odd number and less than 10”);
}
}

This brings up the other if-else construct, the if, else if, else. This construct is useful where two
or more alternatives are available for selection.

The syntax is

if(condition)
statement 1;
else if (condition)
statement 2;
.....................
.....................
else if(condition)
statement n-1;
else
statements n ;

The various conditions are evaluated one by one starting from top to bottom, on reaching a
condition evaluating to true the statement group associated with it are executed and skip other
statements. If none of expression is evaluate to true, then the statement or group of statement
associated with the final else is executed.

The following program demonstrates a legal if-else if-else statement:

[Type text] KIRTHIKA KM /AP/CSE [Type text]


#include<stdio.h>

[Type text] KIRTHIKA KM /AP/CSE [Type text]


#include<conio.h> int
main()
{
int number;
clrscr();
printf (“enter the number\n”);
scanf(“%d”,&number); if(number==0)
printf(“given number is zero\n”); else
if(number>0)
printf(“given number is positive \n”); else
printf(“given number is negative\n”); getch();
return 0;
}

Expressions:

An expression represents a single data item, such as a number or a character. The expression may
consist of a single entity, such as a constant, a variable, an array element or a reference to a
function. It may also consist of some combination of such entities, interconnected by one or more
operators.

Expressions can also represent logical conditions that are either true or false. However
, in C the conditions true and false area represented by the integer values 1 and 0, respectively.

Simple expressions are:

a+b x=y
c=a+b
x<=y
x==y

The first expression involves use of the addition operator (+), this expression represents
the sum of the values assigned to the variables a and b.

The second expression involves the assignment operator (=). In this case, the expression
causes the value represented by y to be assigned to x. \

In the third line, the value of the expression (a+b) is assigned to the variable c.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


#include<stdio.h> int
main()
{
// Variable declaration int
a, b, sum;

// Take two numbers as input from the user


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

// Add the numbers and assign the value to some variable so that the
// calculated value can be used else where sum =
a + b;

// Use the calculated value


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

return 0;
// End of program

1. Fibonacci series in c

Fibonacci series in c programming: c program for Fibonacci series without and with recursion.
Using the code below you can print as many numbers of terms of series as desired. Numbers of
Fibonacci sequence are known as Fibonacci numbers. First few numbers of series are 0, 1, 1, 2, 3,
5, 8 etc, Except first two terms in sequence every other term is the sum of two previous terms, For
example 8 = 3 + 5 (addition of 3, 5). This sequence has many applications in mathematics and
Computer Science.

Fibonacci series in c using for loop


/* Fibonacci Series c language */
#include<stdio.h>

int main()
{
int n, first = 0, second = 1, next, c;
printf("Enter the number of terms\n");
scanf("%d",&n);
printf("First %d terms of Fibonacci series are :-\n",n); for ( c =
0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
[Type text] KIRTHIKA KM /AP/CSE [Type text]
else
{
next = first + second;
first = second; second
= next;
}
printf("%d\n",next);
}

return 0;
}
Output

2. Palindrome Numbers
Palindrome number algorithm

1. Get the number from user.


2. Reverse it.
3. Compare it with the number entered by the user.
4. If both are same then print palindrome number
5. Else print not a palindrome number.

Palindrome number program c


#include <stdio.h> int
main()
{
int n, reverse = 0, temp;
printf("Enter a number to check if it is a palindrome or not\n");
scanf("%d",&n);
temp = n; while(
temp != 0 )
{
reverse = reverse * 10; reverse =
reverse + temp%10;

[Type text] KIRTHIKA KM /AP/CSE [Type text]


temp = temp/10;
}
if ( n == reverse )
printf("%d is a palindrome number.\n", n); else
printf("%d is not a palindrome number.\n", n); return
0;
}

Output:

In-Lab Question Set

SET A

1. The earth was created in 6 days by God because 6 is perfect. Also, the cycle of the moon

is 28 days. You may check whether the given number is a perfect number or not.

2. Honeybees provide an example. In a colony of honeybees there is one special female called
the queen. The other females are worker bees who, unlike the queen bee, produce no eggs.
The male bees do no work and are called drone bees. Males are produced by the queen's
unfertilized eggs, so male bees only have a mother but no father. All the females are produced
when the queen has mated with a male and so have two parents. Females usually end up as
worker bees but some are fed with a special substance called royal jelly which makes them
grow into queens ready to go off to start a new colony when the bees form a swarm and leave
their home (a hive) in search of a place to build a new nest. So female bees have two parents,
a male and a female whereas male bees have just one parent, a female.
a. Let's look at the family tree of a male drone bee.
b. He has 1 parent, a female. He has 2 grandparents, since his mother had two parents, a
male and a female. He has 3 great-grandparents: his grandmother had two parents but
his grandfather had only one. How many great-great-grandparents did he have?
c. Again we see the Fibonacci numbers:

d.
[Type text] KIRTHIKA KM /AP/CSE [Type text]
3. We have three digit number namely “abc”, the user has to calculate a+b+c and he has to print
the digits in reverse order and find the largest of digits given.
4. The investigation of three-digit Armstrong numbers is conducted by adding the cubes of the
digits. This process of cubing the digits can be continually repeated on the result to reveal
some interesting patterns.

a. The process of Strong Arm Iteration works as follows:


i. Begin with an n-digit number.
ii. Raise each digit to the nth power, and compute the sum.
iii. Raise each digit of the result to the nth power, and compute the sum.
iv. Repeat Step 3 until a pattern emerges.

5. Write a program which to find the grace marks for a student using switch. The user should
enter the class obtained by the student and the number of subjects he has failed in. Use the
following logic:
a. If the student gets first class and the number of subjects he failed in is greater than 3,
then he does not get any grace. If the number of subjects he failed in is less than or
equal to 3 then the grace is of 5 marks per subject.
b. If the student gets second class and the number of subjects he failed in is greater than
2, then he does not get any grace. If the number of subjects he failed in is less than or
equal to 2 then the grace is of 4 marks per subject.
c. If the student gets third class and the number of subjects he failed in is greater than 1,
then he does not get any grace. If the number of subjects he failed in is equal to 1 then
the grace is of 5 marks per subject.
6. We need to build a machine which can answer a simple yes/no question. Given an input
integer n, is n prime? Let’s think about what would be inside this machine to make it work.
Machines can only follow a sequence of steps based on some instructions, known as an
algorithm. To warm up, let's find out what algorithm is inside your brain. Answer the
following question: is 49 prime?

[Type text] KIRTHIKA KM /AP/CSE [Type text]


a.
7. Riya is at a grocery store and she needs to find which deal is better by using divisibility rules.
Let's say 2 cans of beans cost $6 and in another store, 4 cans of beans cost $8. Which deal is
better? We know that 6 is divisible by 2, so each can costs $3. We also know that 8 is
divisible by 4, meaning each can costs $2. Help Riya to solve this problem.

Set B

1. In many engineering problems, we need to generate random floating-point values in a specified


interval [a, b]. The computation to convert an integer between 0 and RAND_MAX to a
floating-point value between a and b has three steps. The value from the rand function is first
divided by RAND_MAX to generate a floating-point value between 0 and 1. The value
between 0 and 1 is then multiplied by (the width of the interval [a, b]) to give a value between 0
and The value between 0 and is then added to a to adjust it so that it will be between a and b.
Write a program for generating integers so that it generates 10 random floating-point values
within a user-specified range.

[Type text] KIRTHIKA KM /AP/CSE [Type text]


MARK
S.NO DESCRIPTION WEIGHTAGE AWARDED
1 Algorithm Development 10

2 Flow Chart Development 10

3 Algorithm Implementation 20

4 Experimental Results 10

5 Test Case 20

6 Viva-voce 30

Total 100

Signature of the Faculty with date

[Type text] KIRTHIKA KM /AP/CSE [Type text]


[Type text] KIRTHIKA KM /AP/CSE [Type text]

You might also like