Showing posts with label Programming for Problem Solving. Show all posts
Showing posts with label Programming for Problem Solving. Show all posts

What is a Flowchart? Properties and Flowchart to Check Buzz Number in C Programming


What is a Flowchart?

A flowchart is a graphical representation of an algorithm or process using different symbols such as rectangles, diamonds, ovals, and arrows to show the flow of control step by step.

Flowcharts are widely used in programming, system design, and process documentation because they help visualize logic clearly and intuitively.



Standard Flowchart Symbols

Symbol Shape Use
Start/End Oval Denotes the beginning or end of the flowchart.
Process Rectangle Represents an action, process, or instruction.
Decision Diamond Used for branching based on yes/no or true/false conditions.
Input/Output Parallelogram Indicates data input or output operations.
Flow Lines Arrows Show the direction of control flow between symbols.
Connector Small Circle Connects different parts of flowchart, especially when diagram continues on another page.



Properties of a Good Flowchart

  1. Clarity: It should be easily understandable with well-defined symbols and logical flow.

  2. Logical Sequence: The process should proceed in proper sequence from start to end.

  3. Standard Symbols: Use standard symbols (rectangle for process, diamond for decision, etc.) accepted in flowchart conventions.

  4. Flow Lines: Use arrows to clearly show the direction of flow from one step to another.

  5. Simplicity: Keep it simple and avoid unnecessary details.

  6. Modularity: Break complex processes into sub-processes or separate flowcharts if needed.


Buzz Number Definition

A number is called a Buzz Number if:

  • It ends with digit 7, or

  • It is divisible by 7.

Flowchart to Check Buzz Number




Sample C Program

#include <stdio.h>

int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);

    if (num % 10 == 7 || num % 7 == 0)
        printf("%d is a Buzz number.\n", num);
    else
        printf("%d is not a Buzz number.\n", num);

    return 0;
}

Summary

  • Flowchart: Visual tool using standard symbols to describe an algorithm.

  • Properties: Clear, logical, uses proper symbols, and arrows.

  • Buzz Number: Ends with 7 or divisible by 7.

  • Symbols: Oval (start/end), rectangle (process), diamond (decision), parallelogram (I/O), arrows (flow).


If you found this post helpful, share and explore our other blogs for detailed solutions on PPS with C exam questions!

BCS201 PROGRAMMING FOR PROBLEM SOLVING THEORY EXAMINATION 2023-24 Solution

 Section A

 attempt all questions in brief.

a. 1Nibble =………..Bytes. 

Answer:
1 Nibble = 0.5 Bytes

Explanation: 1 Nibble = 4 bits; 1 Byte = 8 bits → 4/8 = 0.5 Bytes


b. Find the value of variable max in the following code: -

 int a=10, b=20; int max= (a>b)? a: b;  

Answer:
max = 20

Explanation: Since a = 10 and b = 20, the condition (a > b) is false. So the ternary operator returns b.


c. Define Explicit type conversion with suitable example. 

Answer:
Explicit type conversion, also known as type casting, is when a programmer manually converts one data type into another.

Example:

float x = 5.75;

int y = (int)x;  // Explicitly converting float to int

Here, (int)x converts 5.75 to 5 by truncating the decimal part.

d. Write a C program to print all natural numbers from 10 to 100. 

Answer: 

#include <stdio.h>

int main() {

    int i;

    for(i = 10; i <= 100; i++) {

        printf("%d ", i);

    }

    return 0;

}

This program uses a for loop to print natural numbers from 10 to 100.


e. Define Pointer to Pointer.  

Answer:
A Pointer to Pointer is a variable that stores the address of another pointer.

Syntax Example:

int a = 5;

int *p = &a;

int **pp = &p;

Here, pp is a pointer to the pointer p, which in turn points to variable a.

f. Find the output of following code: - 

#include<stdio.h>

 #defien a 2*2+2 

void main () { 

int b,c; b=2/a; 

c=b+4;

printf(“Value of variable b and c are %d%d respectively ”, b,c); 

Answer:
There are two issues:

  1. Typo: #defien should be #define.

  2. Macro expansion issue due to missing parentheses.

Corrected Code:

#include<stdio.h> #define a (2*2+2) // a becomes (2*2+2) = 6 void main() { int b, c; b = 2 / a; // 2 / 6 = 0 c = b + 4; // 0 + 4 = 4 printf("Value of variable b and c are %d%d respectively", b, c); }

Output:Value of variable b and c are 04 respectively.

g. Draw block diagram to represent doubly linked list.

Answer:


Each node in a doubly linked list contains:

  • A pointer to the previous node

  • The data

  • A pointer to the next node

Explanation:

  • The first node’s prev points to NULL.

  • The last node’s next points to NULL.

  • Every node is bidirectionally linked.

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