PROBLEM SOLVING USING C

PROBLEM SOLVING USING C


📘 Unit 1: Introduction to Computer Programming

What is Computer Programming?

A Computer Program is a set of instructions written in a programming language that tells a computer how to perform a specific task.

Examples

  • Calculator Application
  • ATM Software
  • Mobile Apps
  • Online Shopping Websites
  • Student Management System

💾 Types of Software

What is Software?

Software is a collection of programs and instructions that tells a computer what to do. Without software, a computer cannot perform any task.

Software is mainly divided into two types:

  • System Software
  • Application Software

1. System Software

System software controls and manages computer hardware and provides a platform for running applications.

Functions:
  • Controls hardware
  • Manages memory and files
  • Runs applications
  • Provides security
  • Handles input/output devices
Examples:
  • Windows
  • Linux
  • macOS
  • Device Drivers
  • Utility Software

2. Application Software

Application software helps users perform specific tasks like browsing, chatting, or creating documents.

Functions:
  • Helps complete tasks
  • Makes work easier
  • Used in education, business, and personal use
Examples:
  • Instagram
  • Facebook
  • Google Chrome
  • WhatsApp
  • YouTube
  • Snapchat

⚙️ Compiler and Interpreter

Compiler

A compiler translates the entire program into machine language at once.

Interpreter

An interpreter translates the program line-by-line during execution.

🧠 Programming Language Levels

Programming languages are classified into three levels:

  • Machine Level Language
  • Assembly Level Language
  • High-Level Language

1. Machine Level Language (1GL)

Uses binary numbers (0s and 1s). Directly understood by CPU.

10010010 01101101 11001100

2. Assembly Level Language (2GL)

Uses mnemonic codes instead of binary.

MOV A, 10 ADD A, 20 SUB A, 5

3. High-Level Language (3GL)

Easy to read and write using English-like syntax.

#include <stdio.h> int main() { printf("Hello World"); return 0; }

📊 Difference Between Language Levels

🤖 Algorithm

                The Step by Step process to finish a particular task is know as Algorithm. it is written in                         english line statements.

        1.  It is one of the Basic Tools that are used to develop the Problem Solving Logic. 
        2.  An Algorithm provides a Blueprint for writing a program to solve a particular problem. 
        3.  An Algorithm can be implemented in more than one Programming Language. 
        4.  An Algorithm is represented by Flowcharts, Pseudo-Codes. 
        5.  An algorithm has a finite number of steps and some steps may involve decision-making and                    repetition. 

🔥 Features (Characteristics) of Algorithms:

        1. Finiteness: An algorithm should have Finite number of steps. 

        2. Definiteness: Every Statement/instruction in an Algorithm must be clear and unambiguous. 

        3. Input: Every Algorithm must take Zero or one or more number of input values. The input of an             Algorithm can either be given interactively by user or generated internally. 

        4. Output: Every Algorithm must produce an output as result. 

        5. Effectiveness: It should be easily convertible into program. 

        6. Generality: The Algorithm applies to a set of Inputs.

 

     Example Algorithms:

          1. Write an Algorithm for Sum of Two Numbers (Addition of Two Numbers): 

          Step 1: Start 

          Step 2: Read Two Numbers m, n. 

          Step 3: Add m and n, and Store the Result in „Sum‟ (Sum=m + n) 

          Step 4: Display „Sum‟ value 

          Step 5: Stop 


         2. Write an Algorithm for Sub of Two Numbers (Subtraction of Two Numbers): 

          Step 1: Start 

          Step 2: Read Two Numbers m, n. 

          Step 3: Sub m and n, and Store the Result in „Sub‟ (Sub=m - n) 

          Step 4: Display „Sub‟ value 

          Step 5: Stop


         3. Write an Algorithm for Mul of Two Numbers (Multiplication of Two Numbers):

          Step 1: Start 

          Step 2: Read Two Numbers m, n. 

          Step 3: Mul m and n, and Store the Result in „Mul‟ (Mul=m * n) 

          Step 4: Display „Mul‟ value 

          Step 5: Stop


         4. Write an Algorithm For Largest of Two Numbers (Biggest of Two Numbers): 

         Step 1: Start 

         Step 2: Read Two numbers p, q. 

         Step 3: if p>q then Display p is Big 

         Step 4: else Display q is Big 

         Step 5: Stop


        5. Write an Algorithm to find the area og the circle

          Step 1: Start 

          Step 2: Read radius r. 

          Step 3: calculate area. "area" =  Ï€ * r * r

          Step 4: Display „area‟ value 

          Step 5: Stop


       6. Write an Algorithm to find the Sum of three sides of the Triangle.

          Step 1: Start 

          Step 2: Read s1, s2, s3. 

          Step 3: calculate area. "sum" =  s1 + s2 + s3

          Step 4: Display „sum‟ value 

          Step 5: Stop


       7. Write a Algorithm to Calculate the Simple Intrest.

          Step 1: Start 

          Step 2: Read P, R, T. 

          Step 3: calculate area. "intrest" =  (P * R * T) / 100

          Step 4: Display „intrest‟ value 

          Step 5: Stop

Comments

Popular posts from this blog

Data Structure Algorithms

JavaScript