0% found this document useful (0 votes)
69 views2 pages

CTPS Assignment 1: Problem Solving in C

This document outlines the first assignment for the Computational Thinking for Problem Solving course at SVKM’s NMIMS for the academic year 2025-26. It includes instructions for submission, a list of concepts to explain, problem scenarios to solve, and programming tasks to complete using C. The assignment emphasizes understanding computational concepts and programming fundamentals through practical exercises.

Uploaded by

bagera6354
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)
69 views2 pages

CTPS Assignment 1: Problem Solving in C

This document outlines the first assignment for the Computational Thinking for Problem Solving course at SVKM’s NMIMS for the academic year 2025-26. It includes instructions for submission, a list of concepts to explain, problem scenarios to solve, and programming tasks to complete using C. The assignment emphasizes understanding computational concepts and programming fundamentals through practical exercises.

Uploaded by

bagera6354
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

SVKM’s NMIMS

Mukesh Patel School of Technology Management & Engineering /


School of Technology Management & Engineering

B. Tech/MBA Tech Lab and Workbook Academic Year- 2025-26


Year:-First Subject:- Computational Thinking for Problem Solving Semester:- First

Assignment #1
PART A

(TO BE SOLVED BY STUDENTS IN THE WORKBOOK)

CO1: Comprehend problem statements, build logic and draw flowchart (K2)

Important Instructions:

 Complete the assignment at the end of your practical file.


 Write your Name and SAP ID on every page clearly.
 After completion, scan all pages and upload the file as PDF on SAP Student Portal
under Assignment #1 for CTPS.
 Submission Deadline: 11th August 2025

1. Explain the following concepts in your own words with suitable examples:
a. Decomposition
b. Abstraction
c. Pattern Recognition
d. Algorithm
e. Flowchart
2. Interpret the following problem scenarios and outline their computational solutions by
applying decomposition, abstraction, pattern recognition, and algorithm development.
Also, illustrate each with a suitable flowchart.
a. Compute compound interest and display both the interest and the total
amount.
b. For three given sides of a triangle, compute the area and determine whether
the triangle is valid using conditional operator.
3. Describe the basic structure of a C program and illustrate it with a simple example.
SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering /
School of Technology Management & Engineering

B. Tech/MBA Tech Lab and Workbook Academic Year- 2025-26


Year:-First Subject:- Computational Thinking for Problem Solving Semester:- First

4. Explain the following programming elements using suitable examples to clarify their
roles in C programming:
a. Keywords
b. Variables
c. Data Types
d. Formatted Input and Output
e. Operators (all types)
5. Illustrate how to initialize and display your personal details (e.g., name, age, gender,
city, height) using appropriate C data types and character arrays. (Write a Program)
6. Demonstrate how to take input from the user for personal details (name, age, gender,
city, height) and display the output properly. (Write a Program)
7. Interpret how to find and display the ASCII value of an entered character using a C
program.
8. Convert a lowercase letter to its corresponding uppercase letter through a C program
and explain the logic used.
9. Identify the size of fundamental data types (int, float, double, char) in C by writing a
program and explain the observed output
10. Describe a logic to compute the sum of the digits of a 4-digit number entered by the
user. (Write C program, don’t use loop)
11. Illustrate a logic to reverse a 4-digit number entered by the user and draw a flowchart
representing the steps involved. (Write C program, don’t use loop)
12. How to exchange the values of two integer variables using the XOR bitwise operator.
(Write a program)
13. Compare two numbers (for equality) using both XOR and conditional operators in a C
program and explain how the logic works.
14. Write a C program to calculate the BMI. Draw a flowchart for the same. Body Mass
Index is calculated as (BMI = weight / height², where weight is in kg and height in
meters).

Common questions

Powered by AI

Operators in C are instrumental in executing operations. Logical operators like XOR serve specific functions, such as toggling bits for comparison without conditional branches, while conditional operators give straightforward evaluations using branching logic (if-else). Utilizing these operators for number comparisons allows for different methodologies; XOR can evaluate equality by checking if bit differences sum to zero, while the conditional operator plainly assesses conditions, controlling program flow efficiently .

A C program comprises several crucial components: preprocessor commands, main function, variable declarations, statements and expressions, and functions. Preprocessor commands include directives like #include for library inclusions. The main function defines execution entry, while variables store data used and manipulated by statements. Functions encapsulate logical operations and can be reused across programs, which promotes modularity and clarity .

To compute the sum of digits in a 4-digit number without loops, we leverage arithmetic operations: using integer division and modulus. Extract digits by repeatedly dividing and modding the number: thousands (n/1000), hundreds ((n/100)%10), tens ((n/10)%10), and units (n%10), then sum these products of division results to achieve the total without iteration .

Knowing memory allocation sizes for data types like int, float, double, and char is crucial because it affects the precision of computations, optimization of memory use, and system portability. Different systems may allocate varying memory sizes for the same data types, impacting data storage and processing capability. Understanding this aids developers in writing robust, efficient, and compatible programs .

Abstraction involves focusing on the essential details needed to solve a problem while ignoring irrelevant information. In developing algorithms for validating a triangle, abstraction allows programmers to distill mathematical rules such as the triangle inequality theorem, applying it generically without specific numeric examples, which simplifies coding logic. This ensures that the algorithm remains generalizable, accommodating any input set efficiently .

Pattern recognition helps in identifying recurring elements or processes in a problem. For BMI calculations, recognizing the consistent formula (weight divided by the square of the height) guides decision-making about input and processing steps. A flowchart visually aligns actions such as reading inputs, applying the formula, and producing outputs, simplifying complexity into repeatable processes that a computer program can execute efficiently .

Decomposition involves breaking down complex problems into smaller, manageable components. In computing compound interest, decomposition allows for separating the task into sub-tasks, such as calculating interest for a single period, summing up these interim interests, and finally, compounding the sum with the principal amount. This approach streamlines solution development by making each part simpler and easier to handle .

Flowcharts offer a visual roadmap of the logic structure, making abstract processes tangible. For programs like exchanging values using XOR, the flowchart illustrates steps like reading values, applying consecutive XOR operations to swap them. This visual aid clarifies the unique properties of XOR, such as how pairing and unpairing actions exchange values without a temporary variable, enlightening debugging and learning .

Formatted input and output operations, like printf and scanf, enable precise control over data presentation and collection in user interfaces. They allow specification of data types, control character output format (decimal, hexadecimal), improve readability, and ensure accurate data interaction for users. Mastery of these operations ensures user-friendly interfaces and robust code execution by handling varied data input efficiently .

Converting a lowercase to an uppercase letter in C involves leveraging ASCII values, subtracting 32 from the lowercase character code. This understanding underscores familiarity with character encoding, showing ASCII's structured pattern where uppercase and lowercase letters are systematically offset. Recognizing such patterns allows for efficient, arithmetic-based character transformations with simplicity .

You might also like