SlideShare una empresa de Scribd logo
1 de 13
COMPUTER PROGRAMMING
Imtiaz Ali
INTRODUCTION TO COMPUTER PROGRAMMING
1) Comments in C, Program Style, Round one, format specifiers.
2) Variable, identifiers or Names in C and CONSTANTS IN C
3) Working with variable, identifiers or Names in C etc
Why use Comments
• Documentation of variables, functions and their usage.
• Explaining difficult section of code.
• Describes author, program, data, modification changes and revisions.
• Best programmers comment as they write the code not after the fact.
Comments
• The addition of comments inside programs is desirable.
• These may be added to C programs by enclosing them as follows.
Multiple line comment
/* This code will not be compiled and executed*/
• Note that /*opens the comment field and */ closes the comment field
• Comments may span multiple lines
• Comments may not be nested one inside the another
• For example /* and /* and */ */ error generated.
Single line comment
// This will not be executed.
Program Style, Round one, format specifiers
void main(void){printf(“This is the number two:%d”,2);}
• The white space characters(space, tab, newline) are invisible
by compiler.
• C distinguishes between UPPERCASE and LOWERCASE.
Printing Numbers
void main(void)
{
printf(“This is the number two:%d”,2);
}
Format Specifier
• It tells printf function to put a value in String and what format
to use in printing value.
Printing Strings
void main(void)
{
printf(“%s is %d million miles from sun”, “venus”,67);
}
o/p
venus is 67 million miles from sun
Printing Characters
void main(void)
{
printf(“The letter %c is ”, ‘j’);
printf(“pronounced %s”, “jay”);
}
o/p
The letter j is pronounced jay
Variable
•Variable may be the most fundamental aspect of any computer
language.
•Variable is space in computer memory. Set aside for a certain
kind data and given a name for easy reference.
•Variables are used so that, the same space in memory can hold
different times.
•You need to store at least hourly rate and hours worked.
Identifiers or Names in C
• Identifiers in C must begin with a character or underscore and
may be followed by any combination of characters,
underscores or digits 0-9.
Example
summary exit_flag
Jerry7 Number_of_moves
Rule
Variables in lower case
Constant in upper case
void main(void)
{
int num; //variable declared
num=2; // variable assigned value or initialized
printf(“This is number two:%d”,num);
}
• All variables must be defined to specify their
name and set aside storage.
int apples, oranges, mangoes;
Format Specifiers
%c Single character.
%s String.
%d Signed Decimal Integer.
%f floating point(decimal notation).
%e floating point(exponential notation).
%u unsigned decimal integer.
%x unsigned hexadecimal (uses “abcdef”).
%o unsigned octal integer.
Escape Sequences
Escape Sequence Character
a Bell (speaker beeps)
b Backspace (non-erase)
f Form feed/clear screen
n New line
r Carriage Return(return it to begin of line)
t Tab
v Vertical tab
 Backslash
? Question mark
' Single quote
" Double quote
xnn Hexadecimal character code nn
onn Octal character code nn
Working with variable
#include<stdio.h>
#include<conio.h>
void main(void)
{
int first,second,third;
first=10;
second=10;
third=10;
printf(“%d, %d and %d ”,first,second,third);
}
Working with variable
a. Write a program in C for three variables and display its addition.
b. Write a program in C for two variable and display its multiplication.
c. Write a program in C for two variables and display its division.
d. Write a program in C for two variables and display its subtraction.
e. Write a program in C for subject marks and find its percentage.
f. Write a program in C for radius and pi for area of circle.
g. Write a program in C for side of Square and find its Area.
h. Write a program in C for length and width of rectangle and find its Area

Más contenido relacionado

La actualidad más candente

Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageRai University
 
Learn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsLearn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsEng Teong Cheah
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysEng Teong Cheah
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageRai University
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c languageRai University
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageRai University
 
Learn C# Programming - Operators
Learn C# Programming - OperatorsLearn C# Programming - Operators
Learn C# Programming - OperatorsEng Teong Cheah
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_outputAnil Dutt
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
Learning C and C++
Learning C and C++Learning C and C++
Learning C and C++Pagal Bacha
 

La actualidad más candente (20)

Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
Basics of c
Basics of cBasics of c
Basics of c
 
Learn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsLearn C# Programming - Variables & Constants
Learn C# Programming - Variables & Constants
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
C language basics
C language basicsC language basics
C language basics
 
Learn C# Programming - Operators
Learn C# Programming - OperatorsLearn C# Programming - Operators
Learn C# Programming - Operators
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
What is c
What is cWhat is c
What is c
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Learning C and C++
Learning C and C++Learning C and C++
Learning C and C++
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 

Similar a INTRO COMPUTER PROGRAMMING

Similar a INTRO COMPUTER PROGRAMMING (20)

Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
 
Cpu
CpuCpu
Cpu
 
C introduction
C introductionC introduction
C introduction
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
C programming
C programmingC programming
C programming
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
C language
C languageC language
C language
 
fds unit1.docx
fds unit1.docxfds unit1.docx
fds unit1.docx
 
Cnotes
CnotesCnotes
Cnotes
 
C language updated
C language updatedC language updated
C language updated
 
C programming notes
C programming notesC programming notes
C programming notes
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
C-PROGRAMMING.pdf
C-PROGRAMMING.pdfC-PROGRAMMING.pdf
C-PROGRAMMING.pdf
 
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
 
C programming
C programmingC programming
C programming
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 

Más de imtiazalijoono

Embedded systems io programming
Embedded systems   io programmingEmbedded systems   io programming
Embedded systems io programmingimtiazalijoono
 
Embedded systems tools & peripherals
Embedded systems   tools & peripheralsEmbedded systems   tools & peripherals
Embedded systems tools & peripheralsimtiazalijoono
 
Importance of reading and its types.
Importance of reading and its types.Importance of reading and its types.
Importance of reading and its types.imtiazalijoono
 
Negative amplifiers and its types Positive feedback and Negative feedback
Negative amplifiers and its types Positive feedback  and Negative feedbackNegative amplifiers and its types Positive feedback  and Negative feedback
Negative amplifiers and its types Positive feedback and Negative feedbackimtiazalijoono
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierMultistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierimtiazalijoono
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...imtiazalijoono
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge imtiazalijoono
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development processimtiazalijoono
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions imtiazalijoono
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translatorsimtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Conceptsimtiazalijoono
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variableimtiazalijoono
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayimtiazalijoono
 
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,imtiazalijoono
 
Arithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsArithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsimtiazalijoono
 
INTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGINTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGimtiazalijoono
 

Más de imtiazalijoono (20)

Embedded systems io programming
Embedded systems   io programmingEmbedded systems   io programming
Embedded systems io programming
 
Embedded systems tools & peripherals
Embedded systems   tools & peripheralsEmbedded systems   tools & peripherals
Embedded systems tools & peripherals
 
Importance of reading and its types.
Importance of reading and its types.Importance of reading and its types.
Importance of reading and its types.
 
Negative amplifiers and its types Positive feedback and Negative feedback
Negative amplifiers and its types Positive feedback  and Negative feedbackNegative amplifiers and its types Positive feedback  and Negative feedback
Negative amplifiers and its types Positive feedback and Negative feedback
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierMultistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifier
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development process
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translators
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Concepts
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variable
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
 
Arithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsArithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operators
 
INTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGINTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMING
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 

Último

Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 

Último (20)

Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 

INTRO COMPUTER PROGRAMMING

  • 2. INTRODUCTION TO COMPUTER PROGRAMMING 1) Comments in C, Program Style, Round one, format specifiers. 2) Variable, identifiers or Names in C and CONSTANTS IN C 3) Working with variable, identifiers or Names in C etc
  • 3. Why use Comments • Documentation of variables, functions and their usage. • Explaining difficult section of code. • Describes author, program, data, modification changes and revisions. • Best programmers comment as they write the code not after the fact. Comments • The addition of comments inside programs is desirable. • These may be added to C programs by enclosing them as follows. Multiple line comment /* This code will not be compiled and executed*/ • Note that /*opens the comment field and */ closes the comment field • Comments may span multiple lines • Comments may not be nested one inside the another • For example /* and /* and */ */ error generated. Single line comment // This will not be executed.
  • 4. Program Style, Round one, format specifiers void main(void){printf(“This is the number two:%d”,2);} • The white space characters(space, tab, newline) are invisible by compiler. • C distinguishes between UPPERCASE and LOWERCASE. Printing Numbers void main(void) { printf(“This is the number two:%d”,2); }
  • 5. Format Specifier • It tells printf function to put a value in String and what format to use in printing value. Printing Strings void main(void) { printf(“%s is %d million miles from sun”, “venus”,67); } o/p venus is 67 million miles from sun
  • 6. Printing Characters void main(void) { printf(“The letter %c is ”, ‘j’); printf(“pronounced %s”, “jay”); } o/p The letter j is pronounced jay
  • 7. Variable •Variable may be the most fundamental aspect of any computer language. •Variable is space in computer memory. Set aside for a certain kind data and given a name for easy reference. •Variables are used so that, the same space in memory can hold different times. •You need to store at least hourly rate and hours worked. Identifiers or Names in C • Identifiers in C must begin with a character or underscore and may be followed by any combination of characters, underscores or digits 0-9.
  • 8. Example summary exit_flag Jerry7 Number_of_moves Rule Variables in lower case Constant in upper case void main(void) { int num; //variable declared num=2; // variable assigned value or initialized printf(“This is number two:%d”,num); }
  • 9. • All variables must be defined to specify their name and set aside storage. int apples, oranges, mangoes;
  • 10. Format Specifiers %c Single character. %s String. %d Signed Decimal Integer. %f floating point(decimal notation). %e floating point(exponential notation). %u unsigned decimal integer. %x unsigned hexadecimal (uses “abcdef”). %o unsigned octal integer.
  • 11. Escape Sequences Escape Sequence Character a Bell (speaker beeps) b Backspace (non-erase) f Form feed/clear screen n New line r Carriage Return(return it to begin of line) t Tab v Vertical tab Backslash ? Question mark ' Single quote " Double quote xnn Hexadecimal character code nn onn Octal character code nn
  • 12. Working with variable #include<stdio.h> #include<conio.h> void main(void) { int first,second,third; first=10; second=10; third=10; printf(“%d, %d and %d ”,first,second,third); }
  • 13. Working with variable a. Write a program in C for three variables and display its addition. b. Write a program in C for two variable and display its multiplication. c. Write a program in C for two variables and display its division. d. Write a program in C for two variables and display its subtraction. e. Write a program in C for subject marks and find its percentage. f. Write a program in C for radius and pi for area of circle. g. Write a program in C for side of Square and find its Area. h. Write a program in C for length and width of rectangle and find its Area