Language of Logic
Mrs. K. Gowri,
Assistant Professor,
Department of Computer Science with Cognitive Systems,
Sri Ramakrishna College of Arts & Science, Coimbatore.
Agenda
• Introduction
• What is an Algorithm?
• Flowchart.
• Problem and its Algorithm.
• Concepts of a programming language.
• Categories of language
• Elements of programming language..
What is a Programming
Language?
A programming language is a formal language designed to
communicate instructions to a computer or computing device to
perform specific tasks. It provides a structured way of writing code
that the computer can interpret and execute. Programming
languages vary in their syntax, features, and intended use cases.
Importance of Learning a
Programming Language
1 Enhance Problem-
Solving Skills
Learning to code teaches you
how to break down complex
problems and devise logical
solutions.
2 Increase Career
Opportunities
Proficiency in programming is
highly valued in a wide range
of industries, from tech to
finance to healthcare.
3 Unlock Creativity
Programming allows you to bring your ideas to life and create
innovative digital solutions.
What is an Algorithm
• A step-by-step procedure for solving a problem
Example: Suppose, we have to develop an algorithm to convert an integer numerical score (0 to 100) scored by a student in a
particular test into letter grades (A,B,C,D,E) using the following procedure.
Numerical Score Letter grade
Less than 40 E
40 to 50 D
55 to 69 C
70 to 85 B
More than 85 A
Algorithm is defined as follows:
Step 1 INPUT the score of a student
Step 2 If the score is less than 40 then print "E : END
Step 3 If the score is greater than or equal to 40 and less than 55,
then print "D":END of a program
Step 4 If the score is greater than or equal 55 and less than 70-print
"C" :END
Step 5 If the score is greater than or equal to 70 and less than or
equal to 85 print "B" :END
Step 6 If the score is greater than 85 print "A"
Step 7 End of a program.
Flowchart
A flowchart is the graphical or pictorial representation of an algorithm with
the help of different symbols, shapes, and arrows to demonstrate a process or
a program. With algorithms, we can easily understand a program. The main
purpose of using a flowchart is to analyze different methods.
Problem and Its Algorithm with
Flowchart
Problem Statement
Problem Description :
Write Algorithm, Flowchart and Program to Add Two Integers
Example 1 :
Input : a = 3 and b = 7
Output : 10
Explanation : sum of 3 and 7 results to 10
Algorithm
Input : Two numbers num1 and num2
Step 1: Start
Step 2: Declare sum to 0 (This is optional step, during step5 we
can add declaration and assign directly as well)
Step 3: Read number num1
Step 4: Read number num2
Step 5: Add num1 and num2 and assign result to variable sum
Step 6: Print sum
Step 7: Stop
Output: Sum of num1 and num2
#include <stdio.h>
2int main() {
3
4 // Delcare variable Sum
5 int sum;
6
7 // Read numbers number1 and number2
8 int number1, number2;
9 printf("Enter two integers: ");
10 scanf("%d %d", &number1, &number2);
11
12 // Calculate sum
13 sum = number1 + number2;
14
15 // Print calculated sum
16 printf("%d + %d = %d",
number1,number2,sum);
17 return 0;
18}
Output :
Enter number1: 10
Enter number2: 23
10 + 23 = 33
Concept of a Programming Language
Program and Programming: A computer can neither think nor make any judgement’ on its own. Also it is impossible fa
any computer to independently analyze a given data and follow its own method of solution. It needs a program to tell it
what to do. A program is a set of instructions that are arranged in a sequence that guides the computer to solve a
problem.
The process of writing a program is called Programming. Programming is a critical step in data processing. If the system is
not correctly programmed, it delivers information results that cannot be used. There are two ways in which we can
acquire a program. One is to purchase an existing program, which is normally referred to as packaged software and the
other is to prepare a new program from scratch in which case it is called customized software.
There are Two different programming languages.
i) System Programming Languages : System programs are designed to make the computer easier to use. An
example of system software is an operating system. which consists of many other programs for controlling
input output devices, memory. processor etc. To write an operating system. the programmer needs instruction
to control the computer's circuitry (hardware part). For example, instructions, that move data from one
location of storage to a register of the processor. Today C-language is widely used to develop system software.
ii) Application Programming Language: Application programs are &signed for specific computer applications,
such as payroll processing, inventory control etc. To write programs for payroll processing or other
applications, the programmer does not need to control the basic circuitry of a computer. Instead the
programmer n& instructions that make it easy to input data, produce output. do calculations and store and
retrieve data. Programming languages hat are suitable for such application programs support these
instructions but not necessarily the types of instructions needed for development of system programs.
Categories of Languages
Machine Language Assembly Language
LD A, 7 : Load register A with 7
LD B, 10 : Load register B with 10
ADD A, B : A A+B
LD (100). A : Save the result in the location 100
HALT : Halt process
High-level Language
LET X = 7
LET Y = 10
LET SUM = X+Y
PRINT SUM
END
Machine language is a low-
level programming
language that consists of
binary bits i.e. only 0 and 1
Top Programming Languages for Beginners
C/C++
It is suitable for system-software
development and game
programming.
JavaScript
JavaScript is the primary language
for web development, with a low
barrier to entry.
Java
Java is a popular and widely-used
language that emphasizes object-
oriented programming concepts.
Python is a versatile and easy-to-
learn language with a focus on
readability and simplicity.
Python
Syntax and Structure of
Programming Languages
1 Syntax
The set of rules that define the structure and grammar of a programming
language.
2 Data Types
Programming languages use various data types, such as integers, floats, and
strings, to represent and store information.
3 Control Flow
Programming languages provide control structures, like conditionals and
loops, to dictate the order of execution.
Function
A function in C is a set of statements that when called perform some specific task
4
Coding Basics: Variables, Data
Types, and Operators
Variables
Used to store and manipulate data in a program.
Data Types
Specify the kind of data a variable can hold.
Operators
Used to perform mathematical and logical operations.
Control Flow: Conditional
Statements and Loops
If and If-Else
Allows the program to make decisions based on conditions.
Loops – For, While and do while
Repeat a block of code multiple times until a condition is met.
Switch
Provides a more concise way to handle multiple conditions.
Debugging and
Troubleshooting
Syntax Errors Errors in the structure or
grammar of the code.
Runtime Errors Errors that occur during the
execution of the program.
Logic Errors Errors in the algorithm or the
way the code is designed.
Resources and Next Steps
1 Online Tutorials
and Courses
Websites like
Codecademy, Udemy,
and edX offer a wide
range of programming
courses for beginners.
2 Interactive Coding
Platforms
Sites like FreeCodeCamp
and CodeWars provide
hands-on coding
challenges and projects.
3 Programming Books and Documentation
Comprehensive books and official language documentation
can deepen your understanding.
Thank You

Programming str_Language of Logic/c.pptx

  • 1.
    Language of Logic Mrs.K. Gowri, Assistant Professor, Department of Computer Science with Cognitive Systems, Sri Ramakrishna College of Arts & Science, Coimbatore.
  • 2.
    Agenda • Introduction • Whatis an Algorithm? • Flowchart. • Problem and its Algorithm. • Concepts of a programming language. • Categories of language • Elements of programming language..
  • 3.
    What is aProgramming Language? A programming language is a formal language designed to communicate instructions to a computer or computing device to perform specific tasks. It provides a structured way of writing code that the computer can interpret and execute. Programming languages vary in their syntax, features, and intended use cases.
  • 4.
    Importance of Learninga Programming Language 1 Enhance Problem- Solving Skills Learning to code teaches you how to break down complex problems and devise logical solutions. 2 Increase Career Opportunities Proficiency in programming is highly valued in a wide range of industries, from tech to finance to healthcare. 3 Unlock Creativity Programming allows you to bring your ideas to life and create innovative digital solutions.
  • 5.
    What is anAlgorithm • A step-by-step procedure for solving a problem
  • 6.
    Example: Suppose, wehave to develop an algorithm to convert an integer numerical score (0 to 100) scored by a student in a particular test into letter grades (A,B,C,D,E) using the following procedure. Numerical Score Letter grade Less than 40 E 40 to 50 D 55 to 69 C 70 to 85 B More than 85 A Algorithm is defined as follows: Step 1 INPUT the score of a student Step 2 If the score is less than 40 then print "E : END Step 3 If the score is greater than or equal to 40 and less than 55, then print "D":END of a program Step 4 If the score is greater than or equal 55 and less than 70-print "C" :END Step 5 If the score is greater than or equal to 70 and less than or equal to 85 print "B" :END Step 6 If the score is greater than 85 print "A" Step 7 End of a program.
  • 7.
    Flowchart A flowchart isthe graphical or pictorial representation of an algorithm with the help of different symbols, shapes, and arrows to demonstrate a process or a program. With algorithms, we can easily understand a program. The main purpose of using a flowchart is to analyze different methods.
  • 8.
    Problem and ItsAlgorithm with Flowchart Problem Statement Problem Description : Write Algorithm, Flowchart and Program to Add Two Integers Example 1 : Input : a = 3 and b = 7 Output : 10 Explanation : sum of 3 and 7 results to 10 Algorithm Input : Two numbers num1 and num2 Step 1: Start Step 2: Declare sum to 0 (This is optional step, during step5 we can add declaration and assign directly as well) Step 3: Read number num1 Step 4: Read number num2 Step 5: Add num1 and num2 and assign result to variable sum Step 6: Print sum Step 7: Stop Output: Sum of num1 and num2
  • 9.
    #include <stdio.h> 2int main(){ 3 4 // Delcare variable Sum 5 int sum; 6 7 // Read numbers number1 and number2 8 int number1, number2; 9 printf("Enter two integers: "); 10 scanf("%d %d", &number1, &number2); 11 12 // Calculate sum 13 sum = number1 + number2; 14 15 // Print calculated sum 16 printf("%d + %d = %d", number1,number2,sum); 17 return 0; 18} Output : Enter number1: 10 Enter number2: 23 10 + 23 = 33
  • 10.
    Concept of aProgramming Language Program and Programming: A computer can neither think nor make any judgement’ on its own. Also it is impossible fa any computer to independently analyze a given data and follow its own method of solution. It needs a program to tell it what to do. A program is a set of instructions that are arranged in a sequence that guides the computer to solve a problem. The process of writing a program is called Programming. Programming is a critical step in data processing. If the system is not correctly programmed, it delivers information results that cannot be used. There are two ways in which we can acquire a program. One is to purchase an existing program, which is normally referred to as packaged software and the other is to prepare a new program from scratch in which case it is called customized software.
  • 11.
    There are Twodifferent programming languages. i) System Programming Languages : System programs are designed to make the computer easier to use. An example of system software is an operating system. which consists of many other programs for controlling input output devices, memory. processor etc. To write an operating system. the programmer needs instruction to control the computer's circuitry (hardware part). For example, instructions, that move data from one location of storage to a register of the processor. Today C-language is widely used to develop system software. ii) Application Programming Language: Application programs are &signed for specific computer applications, such as payroll processing, inventory control etc. To write programs for payroll processing or other applications, the programmer does not need to control the basic circuitry of a computer. Instead the programmer n& instructions that make it easy to input data, produce output. do calculations and store and retrieve data. Programming languages hat are suitable for such application programs support these instructions but not necessarily the types of instructions needed for development of system programs.
  • 12.
    Categories of Languages MachineLanguage Assembly Language LD A, 7 : Load register A with 7 LD B, 10 : Load register B with 10 ADD A, B : A A+B LD (100). A : Save the result in the location 100 HALT : Halt process High-level Language LET X = 7 LET Y = 10 LET SUM = X+Y PRINT SUM END Machine language is a low- level programming language that consists of binary bits i.e. only 0 and 1
  • 13.
    Top Programming Languagesfor Beginners C/C++ It is suitable for system-software development and game programming. JavaScript JavaScript is the primary language for web development, with a low barrier to entry. Java Java is a popular and widely-used language that emphasizes object- oriented programming concepts. Python is a versatile and easy-to- learn language with a focus on readability and simplicity. Python
  • 14.
    Syntax and Structureof Programming Languages 1 Syntax The set of rules that define the structure and grammar of a programming language. 2 Data Types Programming languages use various data types, such as integers, floats, and strings, to represent and store information. 3 Control Flow Programming languages provide control structures, like conditionals and loops, to dictate the order of execution. Function A function in C is a set of statements that when called perform some specific task 4
  • 15.
    Coding Basics: Variables,Data Types, and Operators Variables Used to store and manipulate data in a program. Data Types Specify the kind of data a variable can hold. Operators Used to perform mathematical and logical operations.
  • 16.
    Control Flow: Conditional Statementsand Loops If and If-Else Allows the program to make decisions based on conditions. Loops – For, While and do while Repeat a block of code multiple times until a condition is met. Switch Provides a more concise way to handle multiple conditions.
  • 17.
    Debugging and Troubleshooting Syntax ErrorsErrors in the structure or grammar of the code. Runtime Errors Errors that occur during the execution of the program. Logic Errors Errors in the algorithm or the way the code is designed.
  • 18.
    Resources and NextSteps 1 Online Tutorials and Courses Websites like Codecademy, Udemy, and edX offer a wide range of programming courses for beginners. 2 Interactive Coding Platforms Sites like FreeCodeCamp and CodeWars provide hands-on coding challenges and projects. 3 Programming Books and Documentation Comprehensive books and official language documentation can deepen your understanding.
  • 19.