SlideShare a Scribd company logo
Fundamentals of Programming languages
(With Reference to C Programming)
Ashwani Kumar
Assistant Professor
PG Department of Computer Science
Baring Union Christian College, Batala(Punjab)
Contents
• Learning Outcome
• Programming
• Language
• Programming Language
• Types of Programming Languages
• Basic concepts of C
• Instructions & its types
• Challenges of learning Programming
Learning Outcomes
Student will able to
Identify the problem
Analyze the problem
Find the possible solutions(Choose one)
Develop the code
Verify and Implement
What is Programming Language?
Programming Language is a language in
which we can write programs to solve some
sort of problem. Here I have used the Word
“program” , program is nothing ,it is just a
group of instructions given to the computer
for solving specific problem.
Types of Programming
Languages
Mainly we have two types of Programming
Languages :
1 High level Programming Languages
2. Low level Programming Languages
Exercise
Comparison of High and Low
Level Language
S. No. High level Languages Low level Languages
1
English like language Language of 0’s and 1’s
2
Close to programmer Close to machine
3
Faster program development Faster program execution
4
Better programming
efficiency
Better machine efficiency
5
eg, Fortran, basic, pascal,c+
+,java,c#.
Machine language and
Assembly language
After the above discussion it is clear that there are
two factors on which Programming Language depends :
• Program execution efficiency
• Program development efficiency
We have a language that has the features of High level
as well as low level Programming Language. It is C
Language, the language of my Reference
Comparison of C with English
ENGLISH C LANGUAGE
Alphabets Alphabets, Digits & Special Symbols
Words Constants, variable & Keywords
Sentences Instructions
Paragraph Programs
Alphabets: A to Z, a to z
Digits : 0 to 9
Special Symbols: ~,! ,@, # , $ , %, ^ ,
&, * , ( , ) ,etc.
Constants: 3x+4y=12
Here 3, 4 and 12 are constants because we
cannot change the value.
x and y are the variable because we can
change the value of x and y.
S. No. Constants Range Memory
Occupied
Example
1. int (Integer) -32,768 to 32,767 2 bytes 2,23,456
2. float(Real) -3.4e38 to +3.4e38 4 bytes 2.0,24.6
3. char
(Character)
-128 to 127 1 byte ‘A’,’a’,’d’,’1’
Types Of Constants
(Restricted to only three)
Variables
,
They are the name given to the location in the memory where
different values are stored
float rate_of_interest;
int amount;
Keywords
,
These are the words whose meaning is already known to the
Compiler.
There are 32 keywords used in C language
int, char, void , for, if, else, do, switch, main, etc.
Instruction
It is a statement which consists of variable, constants, special
symbols and keywords.
There are four types of instructions in C:
1. Type Declaration Instruction
2. Input/output Instruction
3. Arithmetic Instruction
4. Control Instruction
Type Declaration Instruction
It is used to declare the variables in the program.
Any variable in a C program must be declared before
using it. These types of instruction must be written at
the beginning of the program.
int amount;
char ch;
Input/output Instructions
Input: These instructions are used to give input
to the program
Output: These Instructions are used to receive
output from the program.
Arithmetic Instructions
The instructions in which arithmetic operations can be
performed are called arithmetic instructions.
eg. rate_of_interest=(p*r*t)/100;
•Arithmetic operation between integer and integer gives integer result.
•Arithmetic operation between integer and float gives float result.
• Arithmetic operation between float and float gives float result.
Note: Operator and Operand
For example
5/2
5.0/2
2/5
5.0/2.0
Answers: a) 2 b) 2.5 c) 0 d) 2.5
Arithmetic Instructions
a) int c=5/2
b) float c=5/2
c) float c=2/5
d) int c=5.0/2.0
e) float c=9.0/2
f) float c=9/2.0
g) int c=9/2.0;
Answers: a) 2 b) 2.0 c) 0.0 d) 2 e) 4.5 f) 4.5 g)4
Control Instructions
S. No Instruction Type Use
1. Sequence Control
Instruction
Insure the sequential execution
2. Decision Control
Instruction
Allow the Compiler to take the
decision, which instruction is to be
executed next
3. Control Instruction Help the compiler to execute the no.
of instruction repeatedly
4. Case Control Instruction Allow the Compiler to take the
decision, which instruction is to be
executed next
Rules for writing C program
• All the statements are written in small case because
C is case sensitive language.
• Every program must be started from main function
because C is a functional language and must have at
least one function i.e main().
• To improve the readability, blank space must be
inserted between two words.
• Every statement ends with a semicolon(;). Some
exceptions are there, I will explain where it
needed.
So let’s start our first C program for
explaining
Sequence control instructions
/* PROGRAM TO CALCULATE SIMPLE INTEREST*/
#include<conio.h> //HEADER FILE
#include<stdio.h>
main()
{
int p,t; //DECLARATION INSTRUCTIONS
float r,si; //DI
clrscr();
printf("Enter the values of p: "); //OUTPUT INSTRUCTION
scanf("%d",&p); //INPUT INSTRUCTION
printf("nEnter the values of r & t: ");
scanf("%f%d",&r,&t);
si=(p*r*t)/100;
printf("nSimple interest is: %f",si);
getch();
}
OUTPUT IS AS FOLLOW:
Enter the values of p: 100
Enter the values of r & t: 10 2
Simple interest is: 20.000000
DECISION CONTROL INSTRUCTIONS
These instructions help the compiler to take decision which
statements are to be executed next.
There are three types of decision control instructions:
1. if eg. if(condition is true)
execute this statement;
2. if else eg. if(condition is true)
execute this statement;
else
execute this statement;
Working of if statement
/*PROGRAM TO CALCULATE SIMPLE INTEREST USING IF*/
#include<conio.h>
#include<stdio.h>
main()
{
int p,t;
float r,si,tds;
clrscr();
p=1000; //DIRECT METHOD FOR INPUT
t=2;
r=10.0;
si=p*r*t/100;
if(si>100)
{
tds=si*10/100;
si=si-tds;
}
printf("Net Simple Interest Is: %f",si);
getch();
}
OUTPUT IS AS FOLLOW:
NET SIMPLE INTEREST IS: 180.000000
Working of if - else statement
/* PROGRAM TO PRINT THE RESULT OF A STUDENT*/
#include<conio.h>
#include<stdio.h>
main()
{
int roll_no;
float marks;
printf("nENTER THE ROLL NO AND MARKS OF STUDENT: ");
scanf("%d%f",&roll_no,&marks);
if(marks>=40)
printf("nStudent of roll no %d is pass",roll_no);
else
printf("nStudent of roll no %d is fail",roll_no);
getch();
}
OUTPUT IS AS FOLLOW:
ENTER THE ROLL NO AND MARKS OF STUDENT: 1100 56
Student of roll no 1100 is pass
ENTER THE ROLL NO AND MARKS OF STUDENT: 1102 39
Student of roll no 1102 is fail
Word of caution
int i=4;
if(i=5)
printf(“HELLO”);
else
printf(“HI”);
int i=5;
if(i=5)
printf(“HELLO”);
else
printf(“HI”);
int i=4;
if(i= =5);
printf(“HELLO”);
printf(“nHI”);
int i=4;
if(i= =5)
printf(“HELLO”);
printf(“HI”);
else
printf(“GOOD”);
HELL
O
ERROR
HELLO
HI
HELLO
Let us consider the following problem to check our
understanding about conditional statements
“A company insures its driver in the following cases
a) If the driver is married
b) If the driver is unmarried , Male and above 30 years
of age
c) If the driver is unmarried ,Female and above 25
years of age”
Here we have to take decision at 3 levels depending
upon the following factors:
1. Marital status
2. Gender
3. Age
Loop control instructions
There are three types of loops:
1. For loop
2. While loop
3. Do while loop
Every loop control statement has three parts:
1. Initialization
2. Condition
3. Update
FLOW CHART OF SIMPLE INTEREST CALCULATION
The following example shows the
working of For Loop
/* PROGRAM TO CALCULATE SIMPLE INTEREST*/
#include<conio.h>
#include<stdio.h>
main()
{
int p,t,count;
float r,si;
clrscr();
for(count=1;count<=3;count++) //LOOP CONTROL INSTRUCTION OR FOR LOOP
{
printf("nEnter the values of p: ");
scanf("%d",&p);
printf("nEnter the values of r & t: ");
scanf("%f%d",&r,&t);
si=(p*r*t)/100;
printf("nSimple interest is: %f",si);
}
getch();
}
ENTER THE VALUES OF P: 100
ENTER THE VALUES OF R & T: 2 2
SIMPLE INTEREST IS: 4.000000
ENTER THE VALUES OF P: 200
ENTER THE VALUES OF R & T: 2 2
SIMPLE INTEREST IS: 8.000000
ENTER THE VALUES OF P: 300
ENTER THE VALUES OF R & T: 2 5
SIMPLE INTEREST IS: 30.000000
Output for above program is as follow:
Challenges of learning
Programming
 One of the most difficult disciplines to master
 Tight Deadlines
 Have to Learn the whole Life Cycle
 Rapid Change in Technology
 Rapid Change in Behavior of clients
Introduction to Programming with Reference to C programming
Introduction to Programming with Reference to C programming
Closure
Reinforcement
Questioning
Illustration
Skill of explaining
Blackboard writing

More Related Content

Similar to Introduction to Programming with Reference to C programming (20)

PPT
C tutorial
Anurag Sukhija
 
PDF
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Rohit Singh
 
PPTX
1 introduction to c program
NishmaNJ
 
PPTX
Lec 02 Introduction to C Programming.pptx
warriorbotscomp
 
PPTX
C for Engineers
Julie Iskander
 
PDF
C programming
Rounak Samdadia
 
ODP
Programming basics
Bipin Adhikari
 
PPTX
Introduction to c programming
Alpana Gupta
 
DOCX
Complete c programming presentation
nadim akber
 
PPT
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
yatakonakiran2
 
PPTX
C language
Priya698357
 
DOC
C notes for exam preparation
Lakshmi Sarvani Videla
 
PPT
C chap02
Khan Rahimeen
 
PPT
C chap02
Kamran
 
PDF
learn basic to advance C Programming Notes
bhagadeakshay97
 
PPTX
C programming language:- Introduction to C Programming - Overview and Importa...
SebastianFrancis13
 
PPTX
Microcontroller lec 3
Ibrahim Reda
 
C tutorial
Anurag Sukhija
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Rohit Singh
 
1 introduction to c program
NishmaNJ
 
Lec 02 Introduction to C Programming.pptx
warriorbotscomp
 
C for Engineers
Julie Iskander
 
C programming
Rounak Samdadia
 
Programming basics
Bipin Adhikari
 
Introduction to c programming
Alpana Gupta
 
Complete c programming presentation
nadim akber
 
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
yatakonakiran2
 
C language
Priya698357
 
C notes for exam preparation
Lakshmi Sarvani Videla
 
C chap02
Khan Rahimeen
 
C chap02
Kamran
 
learn basic to advance C Programming Notes
bhagadeakshay97
 
C programming language:- Introduction to C Programming - Overview and Importa...
SebastianFrancis13
 
Microcontroller lec 3
Ibrahim Reda
 

Recently uploaded (20)

PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Ad

Introduction to Programming with Reference to C programming

  • 1. Fundamentals of Programming languages (With Reference to C Programming) Ashwani Kumar Assistant Professor PG Department of Computer Science Baring Union Christian College, Batala(Punjab)
  • 2. Contents • Learning Outcome • Programming • Language • Programming Language • Types of Programming Languages • Basic concepts of C • Instructions & its types • Challenges of learning Programming
  • 3. Learning Outcomes Student will able to Identify the problem Analyze the problem Find the possible solutions(Choose one) Develop the code Verify and Implement
  • 4. What is Programming Language? Programming Language is a language in which we can write programs to solve some sort of problem. Here I have used the Word “program” , program is nothing ,it is just a group of instructions given to the computer for solving specific problem.
  • 5. Types of Programming Languages Mainly we have two types of Programming Languages : 1 High level Programming Languages 2. Low level Programming Languages
  • 7. Comparison of High and Low Level Language S. No. High level Languages Low level Languages 1 English like language Language of 0’s and 1’s 2 Close to programmer Close to machine 3 Faster program development Faster program execution 4 Better programming efficiency Better machine efficiency 5 eg, Fortran, basic, pascal,c+ +,java,c#. Machine language and Assembly language
  • 8. After the above discussion it is clear that there are two factors on which Programming Language depends : • Program execution efficiency • Program development efficiency We have a language that has the features of High level as well as low level Programming Language. It is C Language, the language of my Reference
  • 9. Comparison of C with English ENGLISH C LANGUAGE Alphabets Alphabets, Digits & Special Symbols Words Constants, variable & Keywords Sentences Instructions Paragraph Programs
  • 10. Alphabets: A to Z, a to z Digits : 0 to 9 Special Symbols: ~,! ,@, # , $ , %, ^ , &, * , ( , ) ,etc. Constants: 3x+4y=12 Here 3, 4 and 12 are constants because we cannot change the value. x and y are the variable because we can change the value of x and y.
  • 11. S. No. Constants Range Memory Occupied Example 1. int (Integer) -32,768 to 32,767 2 bytes 2,23,456 2. float(Real) -3.4e38 to +3.4e38 4 bytes 2.0,24.6 3. char (Character) -128 to 127 1 byte ‘A’,’a’,’d’,’1’ Types Of Constants (Restricted to only three)
  • 12. Variables , They are the name given to the location in the memory where different values are stored float rate_of_interest; int amount; Keywords , These are the words whose meaning is already known to the Compiler. There are 32 keywords used in C language int, char, void , for, if, else, do, switch, main, etc.
  • 13. Instruction It is a statement which consists of variable, constants, special symbols and keywords. There are four types of instructions in C: 1. Type Declaration Instruction 2. Input/output Instruction 3. Arithmetic Instruction 4. Control Instruction
  • 14. Type Declaration Instruction It is used to declare the variables in the program. Any variable in a C program must be declared before using it. These types of instruction must be written at the beginning of the program. int amount; char ch;
  • 15. Input/output Instructions Input: These instructions are used to give input to the program Output: These Instructions are used to receive output from the program.
  • 16. Arithmetic Instructions The instructions in which arithmetic operations can be performed are called arithmetic instructions. eg. rate_of_interest=(p*r*t)/100; •Arithmetic operation between integer and integer gives integer result. •Arithmetic operation between integer and float gives float result. • Arithmetic operation between float and float gives float result. Note: Operator and Operand For example 5/2 5.0/2 2/5 5.0/2.0 Answers: a) 2 b) 2.5 c) 0 d) 2.5
  • 17. Arithmetic Instructions a) int c=5/2 b) float c=5/2 c) float c=2/5 d) int c=5.0/2.0 e) float c=9.0/2 f) float c=9/2.0 g) int c=9/2.0; Answers: a) 2 b) 2.0 c) 0.0 d) 2 e) 4.5 f) 4.5 g)4
  • 18. Control Instructions S. No Instruction Type Use 1. Sequence Control Instruction Insure the sequential execution 2. Decision Control Instruction Allow the Compiler to take the decision, which instruction is to be executed next 3. Control Instruction Help the compiler to execute the no. of instruction repeatedly 4. Case Control Instruction Allow the Compiler to take the decision, which instruction is to be executed next
  • 19. Rules for writing C program • All the statements are written in small case because C is case sensitive language. • Every program must be started from main function because C is a functional language and must have at least one function i.e main(). • To improve the readability, blank space must be inserted between two words. • Every statement ends with a semicolon(;). Some exceptions are there, I will explain where it needed.
  • 20. So let’s start our first C program for explaining Sequence control instructions /* PROGRAM TO CALCULATE SIMPLE INTEREST*/ #include<conio.h> //HEADER FILE #include<stdio.h> main() { int p,t; //DECLARATION INSTRUCTIONS float r,si; //DI clrscr(); printf("Enter the values of p: "); //OUTPUT INSTRUCTION scanf("%d",&p); //INPUT INSTRUCTION printf("nEnter the values of r & t: "); scanf("%f%d",&r,&t); si=(p*r*t)/100; printf("nSimple interest is: %f",si); getch(); } OUTPUT IS AS FOLLOW: Enter the values of p: 100 Enter the values of r & t: 10 2 Simple interest is: 20.000000
  • 21. DECISION CONTROL INSTRUCTIONS These instructions help the compiler to take decision which statements are to be executed next. There are three types of decision control instructions: 1. if eg. if(condition is true) execute this statement; 2. if else eg. if(condition is true) execute this statement; else execute this statement;
  • 22. Working of if statement /*PROGRAM TO CALCULATE SIMPLE INTEREST USING IF*/ #include<conio.h> #include<stdio.h> main() { int p,t; float r,si,tds; clrscr(); p=1000; //DIRECT METHOD FOR INPUT t=2; r=10.0; si=p*r*t/100; if(si>100) { tds=si*10/100; si=si-tds; } printf("Net Simple Interest Is: %f",si); getch(); } OUTPUT IS AS FOLLOW: NET SIMPLE INTEREST IS: 180.000000
  • 23. Working of if - else statement /* PROGRAM TO PRINT THE RESULT OF A STUDENT*/ #include<conio.h> #include<stdio.h> main() { int roll_no; float marks; printf("nENTER THE ROLL NO AND MARKS OF STUDENT: "); scanf("%d%f",&roll_no,&marks); if(marks>=40) printf("nStudent of roll no %d is pass",roll_no); else printf("nStudent of roll no %d is fail",roll_no); getch(); }
  • 24. OUTPUT IS AS FOLLOW: ENTER THE ROLL NO AND MARKS OF STUDENT: 1100 56 Student of roll no 1100 is pass ENTER THE ROLL NO AND MARKS OF STUDENT: 1102 39 Student of roll no 1102 is fail
  • 25. Word of caution int i=4; if(i=5) printf(“HELLO”); else printf(“HI”); int i=5; if(i=5) printf(“HELLO”); else printf(“HI”); int i=4; if(i= =5); printf(“HELLO”); printf(“nHI”); int i=4; if(i= =5) printf(“HELLO”); printf(“HI”); else printf(“GOOD”); HELL O ERROR HELLO HI HELLO
  • 26. Let us consider the following problem to check our understanding about conditional statements “A company insures its driver in the following cases a) If the driver is married b) If the driver is unmarried , Male and above 30 years of age c) If the driver is unmarried ,Female and above 25 years of age” Here we have to take decision at 3 levels depending upon the following factors: 1. Marital status 2. Gender 3. Age
  • 27. Loop control instructions There are three types of loops: 1. For loop 2. While loop 3. Do while loop Every loop control statement has three parts: 1. Initialization 2. Condition 3. Update
  • 28. FLOW CHART OF SIMPLE INTEREST CALCULATION
  • 29. The following example shows the working of For Loop /* PROGRAM TO CALCULATE SIMPLE INTEREST*/ #include<conio.h> #include<stdio.h> main() { int p,t,count; float r,si; clrscr(); for(count=1;count<=3;count++) //LOOP CONTROL INSTRUCTION OR FOR LOOP { printf("nEnter the values of p: "); scanf("%d",&p); printf("nEnter the values of r & t: "); scanf("%f%d",&r,&t); si=(p*r*t)/100; printf("nSimple interest is: %f",si); } getch(); }
  • 30. ENTER THE VALUES OF P: 100 ENTER THE VALUES OF R & T: 2 2 SIMPLE INTEREST IS: 4.000000 ENTER THE VALUES OF P: 200 ENTER THE VALUES OF R & T: 2 2 SIMPLE INTEREST IS: 8.000000 ENTER THE VALUES OF P: 300 ENTER THE VALUES OF R & T: 2 5 SIMPLE INTEREST IS: 30.000000 Output for above program is as follow:
  • 31. Challenges of learning Programming  One of the most difficult disciplines to master  Tight Deadlines  Have to Learn the whole Life Cycle  Rapid Change in Technology  Rapid Change in Behavior of clients