0% found this document useful (0 votes)
258 views11 pages

Flow Charts Books For Flow Chats Flowchart in Programming: C Questions and Answers

The document discusses flowcharts and their use in programming. It provides examples of flowcharts to check if a number is prime, find the largest of three numbers, find the roots of a quadratic equation, and calculate the Fibonacci series up to 1000. It also discusses the common symbols used in flowcharts and provides a table describing these symbols and their purposes.

Uploaded by

Ante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views11 pages

Flow Charts Books For Flow Chats Flowchart in Programming: C Questions and Answers

The document discusses flowcharts and their use in programming. It provides examples of flowcharts to check if a number is prime, find the largest of three numbers, find the roots of a quadratic equation, and calculate the Fibonacci series up to 1000. It also discusses the common symbols used in flowcharts and provides a table describing these symbols and their purposes.

Uploaded by

Ante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

C questions and answers

Flow Charts

Flow Charts
books for flow chats
Flowchart In Programming
Flowchart is a diagrammatic representation of an algorithm. Flowchart are very helpful in
writing program and explaining program to others.

Symbols Used In Flowchart


Different symbols are used for different states in flowchart, For example: Input/Output and
decision making has different symbols. The table below describes all the symbols that are used in
making flowchart
Symbol Purpose Description
Used to indicate the flow of logic by connecting
Flow line
symbols.

Terminal(Stop/Start) Used to represent start and end of flowchart.

Input/Output Used for input and output operation.

Processing Used for airthmetic operations and data-manipulations.

Used to represent the operation in which there are two


Desicion
alternatives, true and false.

On-page Connector Used to join different flowline

Off-page Connector Used to connect flowchart portion on different page.

Predefined Used to represent a group of statements performing one


Process/Function processing task.

Examples of flowcharts in programming


Draw a flowchart to add two numbers entered by user.

Draw flowchart to find the largest among three different


numbers entered by user.
Draw a flowchart to find all the roots of a quadratic
equation ax2+bx+c=0

Draw a flowchart to find the Fibonacci series till term≤1000.


Though, flowchart is useful in efficient coding, debugging and analysis of a program, drawing
flowchart in very complicated in case of complex programs and often ignored.

Q  Finding Prime Numbers Flow Chart - RFFlow

A Flow Chart for Finding


Prime Numbers
Descriptio Prime numbers are positive
n themselves. By definition, n
numbers. The list of the firs

2, 3, 5, 7, 11, 13, 17, 19, 23,


you can divide 5 by 1 evenl
divide 5 by any other intege

5/1 = 5
5/2 = 2 plus a remainder
5/3 = 1 plus a remainder
5/4 = 1 plus a remainder
5/5 = 1
5/6 = 0 plus a remainder
...   = 0 plus a remainder

Now look at the number 4 w

4/1 = 4
4/2 = 2
4/3 = 1 plus a remainder
4/4 = 1
4/5 = 0 plus a remainder
...  = 0 plus a remainder

The number 4 can be divide

The flowchart shown above


returns whether it is prime o
"IsThisNumberPrime."  Firs
Then it checks to make sure
integers, 0, and 1 are not co

Next the function tries to div


forth, to see if it divides any
input number is divided eve
the input number.
You give the function a number and the output is "Yes" if the number is prime, or
"No" if it is not.

Now suppose you want to calculate the first 100 prime numbers. A flowchart to
show that process is shown below.

The flowchart above starts with the number 2 and checks each number 3, 4, 5, and
so forth. Each time it finds a prime it prints the number and increments a counter.
When the counter hits 100, it stops the process. To determine whether a number is
prime, it calls the function "IsThisNumberPrime" which is shown at the top of this
page.

The first few primes are quickly calculated, but as the primes get further apart the
computation time increases. Finding large primes is a task for super computers.

Drawing If you haven't already done so, first download the free trial version of RFFlow. It
Instructio will allow you to open any chart and make modifications.
ns
Once RFFlow is installed, you can open the above charts in RFFlow.  Click on
prime-numbers.flo for the top flow chart or finding-prime-numbers.flo for the
bottom flow chart. From there you can zoom in, edit, and print these sample charts.
It is often easier to modify an existing chart than to draw it from scratch.

To draw this flow chart without downloading it, run RFFlow, click on the More
Shapes button , scroll and open the Flowcharting folder, click
the Physical Flowcharting stencil and click the Add Stencil button.

if else statement and flowchart


Decision Control Statements and Flowchart

The if Statement
It is used to execute an instruction or sequence/block of
instruction only if a condition is fulfilled.
Difference forms of implements if-statement are:

 Simple if statement
 if-else statement
 Nested if-else statement
 else if statement

Figure: Simple if statement syntax and flowchart

Figure: if-else statement syntax and flowchart

Nested if-else statement


In nested if...else statement, an entire if...else
construct is written within either the body of the if
statement or the body of  an else statement.
The syntax is as follows:
if(condition_1)
{
 if(condition_2)
 {
   block statement_1;
 }
 else
 {
   block statement_2;
 }
}
else
{
  block statement_3;
}
block statement_4;

Figure: nested if-else statement flowchart

Else if statement
It is used in multi-way decision on several conditions.
This works by cascading comparisons. As soon as one of
the conditions is true, the statement or block of
statements following them is executed and no further
comparison are performed.
The else...if syntax is as follows:

if(condition_1)
  block statement_1;
else if(condition_2)
  block statement_2;
else if(condition_n)
  block statement_n;
else
  default statement;

Figure: flowchart for else...if statement

Flowchart for finding Armstrong number

Q. Write down the program for finding Armstrong number


and also draw flowchart.

Ans.

for Armstrong number C program source code click below


link:
Finding Armstrong number C program

Flowchart for finding Armstrong number C


program:
Figure: Flowchart for finding number is 
Armstrong or not C program

Factorial C program,Algorithm,Flowchart
Q. Write a C program to find the factorial value of a
number. Also write the algorithm and draw flowchart.

Ans.

/*c program to find out factorial value of a number*/


#include<stdio.h>
#include<conio.h>
int main()
{
 int n,i,fact=1;
 printf("Enter any number : ");
 scanf("%d", &n);
 for(i=1; i<=n; i++)
    fact = fact * i;
 printf("Factorial value of %d = %d",n,fact);
 return 0;
}

The output of above program would be:

Algorithm for calculate factorial value of a number:

[algorithm to calculate the factorial of a number]


step 1. Start
step 2. Read the number n
step 3. [Initialize]
        i=1, fact=1
step 4. Repeat step 4 through 6 until i=n
step 5. fact=fact*i
step 6. i=i+1
step 7. Print fact
step 8. Stop
[process finish of calculate the factorial value of a
number]

Flowchart for calculate factorial value of a number:

Figure: Flowchart for calculate factorial value of

a number C program

Flowchart for prime number


Q. Draw the flowchart diagram for check a number is prime
number or not.

Ans.

Flowchart for check a number is prime or not as


following:
Figure: Flowchart for
check given number is
prime number or not 

You might also like