0% found this document useful (0 votes)
19 views6 pages

Tejaswini

12th

Uploaded by

abishek2461
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)
19 views6 pages

Tejaswini

12th

Uploaded by

abishek2461
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/ 6

1.

Algorithms and Flowcharts:

a) Sum of Digits

Algorithm:

1. Start

2. Input a number (n)

3. Initialize sum = 0

4. While n > 0:

o Get the last digit (digit = n % 10)

o Add digit to sum

o Remove last digit (n = n / 10)

5. Output the sum

6. Stop

Flowchart:
b) Sum of Positive and Negative Integers

Algorithm:

1. Start

2. Input an integer list

3. Initialize pos_sum = 0 and neg_sum = 0

4. For each integer in the list:

o If integer is positive, add to pos_sum

o If integer is negative, add to neg_sum

5. Output pos_sum and neg_sum

6. Stop

Flowchart:

c) Average of Students' Marks

Algorithm:

1. Start

2. Input number of students (n)

3. Initialize total = 0

4. For each student, input marks and add to total


5. Calculate average = total / n

6. Output the average

7. Stop

Flowchart:

2. Conversion between Binary and Decimal:

a) Binary to Decimal Conversion:

To convert a binary number to decimal:

1. Start

2. Input binary number

3. Initialize decimal = 0, position = 0

4. For each digit in the binary number (starting from the right):

o Multiply digit by 2^position

o Add result to decimal

o Increment position

5. Output decimal value


6. Stop

b) Decimal to Binary Conversion:

To convert a decimal number to binary:

1. Start

2. Input decimal number

3. Initialize binary = ""

4. While decimal > 0:

o Divide the number by 2, note the remainder

o Append remainder to binary string

o Update decimal = decimal / 2

5. Output binary string

6. Stop

3. Explanation of Algorithm and Flowchart:

 Algorithm: A step-by-step procedure or a set of rules to solve a problem or perform a task. It


is written in simple language and not in any specific programming language.

 Flowchart: A graphical representation of an algorithm. It uses symbols such as rectangles


(process steps), diamonds (decisions), and arrows (flow of control) to illustrate the solution
flow.

4. Tokens and Operations in C:

Tokens in C:

 Keywords: Reserved words (e.g., int, return, if)

 Identifiers: Names for variables, functions, etc.

 Literals: Constants like numbers (5), characters ('a')

 Operators: Symbols like +, -, *, used for computations

 Punctuation: Symbols like ;, ,, {}, etc.

 Comments: Notes for the programmer (/* */ or //)

Operations in C:

 Arithmetic Operators: +, -, *, /, %

 Relational Operators: ==, !=, <, >, <=, >=

 Logical Operators: &&, ||, !


 Bitwise Operators: &, |, ^, ~

 Assignment Operators: =, +=, -=, etc.

5. Problem-Solving Techniques:

1. Define the problem: Understand what needs to be solved.

2. Break down into smaller tasks: Divide complex problems into simpler sub-problems.

3. Algorithm design: Develop a step-by-step solution.

4. Coding: Implement the solution in a programming language.

5. Testing: Run the program and check for errors.

6. Optimization: Improve the efficiency of the solution if necessary.

6. Data Encoding and Decoding:

 Data Encoding: The process of converting data from one form to another. For example,
converting text data into binary format so computers can understand and process it.

 Data Decoding: The reverse of encoding, where encoded data is converted back to its
original format, such as converting binary back into readable text.

Encoding ensures data can be stored and transmitted efficiently, while decoding restores the data for
its intended use.

7. Data Types in C:

Basic Data Types:

 int: Integer (e.g., 3, -2)

 float: Floating-point numbers (e.g., 3.14)

 char: Single characters (e.g., 'a', 'b')

Derived Data Types:

 Array: A collection of elements of the same type.

 Pointer: A variable that holds the address of another variable.

 Structure: A user-defined data type that groups different types of data.

Enumeration:

 enum: A user-defined type consisting of a set of named integral constants.

8. Compiler:
A compiler is a program that translates high-level source code written in languages like C, C++, or
Java into machine language (binary) so that it can be executed by a computer.

Key Steps in Compilation:

1. Lexical Analysis: Breaking the code into tokens.

2. Syntax Analysis: Checking the structure of the code.

3. Semantic Analysis: Checking for meaningfulness (e.g., type checking).

4. Code Optimization: Improving the efficiency of the code.

5. Code Generation: Converting into machine code.

9. DMA (Direct Memory Access):

Direct Memory Access (DMA) is a feature that allows peripherals (like disk drives, sound cards, etc.)
to directly transfer data to and from memory without involving the CPU. This frees up the CPU to
perform other tasks while the data transfer is happening in the background, improving system
performance.

You might also like