SlideShare a Scribd company logo
Input Operations,
Arrays, Declarations, Expressions,
Statements, Symbolic constant
PROGRAMMING IN C
Revision
•It is possible to utilize an uppercase keyword as an identifier.
•Find out whether following are valid identifier. If not why?
◦ 12,245
◦ 36.0
◦ 10 20 30
◦ 123-45-6789
◦ 0900
PROGRAMMING IN C
unsigned and long integer constants
PROGRAMMING IN C
Average of Three Numbers
step 1: Get the input of three real numbers and store in n1,n2, n3
step 2: Calculate Total <- n1 + n2 + n3
step 3: Calculate average <- Total / 3
step 4: Print Total and average
PROGRAMMING IN C
Simple Interest Calculation ??????????????
PROGRAMMING IN C
Simple Interest Calculation
#include<stdio.h>
int main( )
{
int p, n ;
float r, si ;
p = 1000 ;
n = 3 ;
r = 8.5 ;
si = p * n * r / 100 ;
printf ( "%f" , si ) ;
}
PROGRAMMING IN C
Input operations
• Input operations are used to read user input from the keyboard
• scanf() function is used to read multiple data values of different data types from the keyboard
Syntax:
scanf(“control string”, arg1, arg2, ………. argn);
 Control string (format string) specifies the field format
 Arguments arg1, arg2, …, argn specify the address of locations where
the data is stored
Inputting integer numbers:
%d
Percentage sign (%) indicates conversion specification, a data type character ( or type specifier)
Example:
scanf(“%d %d”, &number1, &number2);
PROGRAMMING IN C
Input operations(cont…)
Inputting real numbers: %f
Example:
scanf(“%f %f”, &number1, &number2);
This statement will read the data: 50.35 23.0345
Inputting character strings: %s or %c
Example:
scanf(“ %s ”, name);
This statement will read the data: SASTRA
PROGRAMMING IN C
Input operations(cont…)
PROGRAMMING IN C
Home Work
1)Area of Rectangle
2)Area of Triangle
3)Farenheit to celcius conversion
4)Celcius to Farenheit conversion
PROGRAMMING IN C
Array
An array is an identifier that refers to a collection of data items that all have the same name.
The data items must all be of the same type
The individual array elements are distinguished from one another by the value that is assigned
to a subscript.
Example
x is a 10-element array.
◦ The first element is referred to as x [ 0J ,the second as x [ 1J ,and so on.
◦ The last element will be x [9J .
If the array contains n elements, the subscript will be an integer quantity whose values range
from 0 to n-1 .
PROGRAMMING IN C
Array (Cont….)
n-character string will require an (n+l )-element array, because of the null character (O) that is
automatically placed at the end of the string.
PROGRAMMING IN C
Declarations
A declaration associates a group of variables with a specific data type.
All variables must be declared before they can appear in executable statements
It consists of a data type, followed by one or more variable names, ending with a semicolon
PROGRAMMING IN C
Declarations (Cont…)
Initial values can be assigned to variables within a type declaration
PROGRAMMING IN C
EXPRESSIONS
An expression represents a single data item, such as a number or a character.
It may consist of a single entity, such as a constant, a variable, an array element or a reference
to a function.
It may also consist of some combination of such entities, interconnected by one or more
operators.
It can also represent logical conditions that are either true or false
true and false are represented by the integer values 1 and 0, respectively.
 Examples are shown there
PROGRAMMING IN C
STATEMENTS
A statement causes the computer to carry out some action.
Three different classes
◦ expression statements
◦ compound statements and
◦ control statements
Expression Statement
o consists of an expression followed by a semicolon.
o Several expression statements are shown below.
o a = 3;
o c = a + b ;
o ++i;
o p r i n t f ("Area = %f area) ;
PROGRAMMING IN C
STATEMENTS(cont..)
Compound statement
◦ A compound statement consists of several individual statements enclosed within a pair of braces { }.
◦ a compound statement does not end with a semicolon
◦ A typical compound statement is shown below.
{
p i = 3.141593;
circumference = 2. * p i * radius;
area = p i * radius * radius;
}
Control Statement
Control statements are used to create special program features, such as logical tests, loops and branches.
PROGRAMMING IN C
STATEMENTS(cont..)
Example
while (count <= n) {
p r i n t f ( ' x = ' ) ;
scanf ( "Skf" , &x) ;
sum += x;
++count;
}
PROGRAMMING IN C
Symbolic Constants
A symbolic constant is a name that substitutes for a sequence of characters.
The characters may represent a numeric constant, a character constant or a string constant.
Thus, a symbolic constant allows a name to appear in place of those constant
When a program is compiled, each occurrence of a symbolic constant is replaced by its
corresponding character sequence.
It usually defined at the beginning of a program
typically written in uppercase letters
does not end with a semicolon
PROGRAMMING IN C
Symbolic Constants(contd…)
Examples
#define TAXRATE 0.23
#define P I 3.141593
#define TRUE 1
#define FALSE 0
#define FRIEND "Susan“
Scenario 1
area = PI * radius * radius; statement will become area = 3.141593 * radius * radius;
PROGRAMMING IN C
Symbolic Constants(contd…)
Scenario2
#define CONSTANT 6.023E23
……
….
p r i n t f ( "CONSTANT = %f “,CONSTANT) ;
......
...... p r i n t f statement would become p r i n t f ( "CONSTANT = %f 6.023E23) ; ,
during the compilation process.
Advantage
readily identified than the information that they represent
easier to change the value of a single symbolic constant than to change every
occurrence of some numerical constant that may appear in several places within the
program.
PROGRAMMING IN C

More Related Content

Similar to 3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx

presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxKrishanPalSingh39
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)SURBHI SAROHA
 
java or oops class not in kerala polytechnic 4rth semester nots j
java or oops class not in kerala polytechnic  4rth semester nots jjava or oops class not in kerala polytechnic  4rth semester nots j
java or oops class not in kerala polytechnic 4rth semester nots jishorishore
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3Vince Vo
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingAniket Patne
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdfMaryJacob24
 

Similar to 3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx (20)

presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
java or oops class not in kerala polytechnic 4rth semester nots j
java or oops class not in kerala polytechnic  4rth semester nots jjava or oops class not in kerala polytechnic  4rth semester nots j
java or oops class not in kerala polytechnic 4rth semester nots j
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
2. operator
2. operator2. operator
2. operator
 
C faq pdf
C faq pdfC faq pdf
C faq pdf
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
 
Basics of c
Basics of cBasics of c
Basics of c
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT IIC PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 

More from ganeshkarthy

Lecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXLecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXganeshkarthy
 
Lecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXLecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXganeshkarthy
 
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTXLecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTXganeshkarthy
 
C_Language_PS&PC_Notes.ppt
C_Language_PS&PC_Notes.pptC_Language_PS&PC_Notes.ppt
C_Language_PS&PC_Notes.pptganeshkarthy
 
CLOUD_COMPUTING_UNIT_2.pdf
CLOUD_COMPUTING_UNIT_2.pdfCLOUD_COMPUTING_UNIT_2.pdf
CLOUD_COMPUTING_UNIT_2.pdfganeshkarthy
 
CLOUD_COMPUTING_UNIT_1.pdf
CLOUD_COMPUTING_UNIT_1.pdfCLOUD_COMPUTING_UNIT_1.pdf
CLOUD_COMPUTING_UNIT_1.pdfganeshkarthy
 
Asynchronous Frameworks.pptx
Asynchronous Frameworks.pptxAsynchronous Frameworks.pptx
Asynchronous Frameworks.pptxganeshkarthy
 
Green computing PPT Notes.ppt
Green computing PPT Notes.pptGreen computing PPT Notes.ppt
Green computing PPT Notes.pptganeshkarthy
 
OOPS(CS8392)_Unit-I_Notes.ppt
OOPS(CS8392)_Unit-I_Notes.pptOOPS(CS8392)_Unit-I_Notes.ppt
OOPS(CS8392)_Unit-I_Notes.pptganeshkarthy
 
Unit-II(STATIC UML DIAGRAMS).ppt
Unit-II(STATIC UML DIAGRAMS).pptUnit-II(STATIC UML DIAGRAMS).ppt
Unit-II(STATIC UML DIAGRAMS).pptganeshkarthy
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docxUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docxganeshkarthy
 
Unit-1_Notes(OOAD).pdf
Unit-1_Notes(OOAD).pdfUnit-1_Notes(OOAD).pdf
Unit-1_Notes(OOAD).pdfganeshkarthy
 

More from ganeshkarthy (13)

Lecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXLecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTX
 
Lecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTXLecture-5-Linear Regression-Tutorials.PPTX
Lecture-5-Linear Regression-Tutorials.PPTX
 
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTXLecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
 
C_Language_PS&PC_Notes.ppt
C_Language_PS&PC_Notes.pptC_Language_PS&PC_Notes.ppt
C_Language_PS&PC_Notes.ppt
 
CLOUD_COMPUTING_UNIT_2.pdf
CLOUD_COMPUTING_UNIT_2.pdfCLOUD_COMPUTING_UNIT_2.pdf
CLOUD_COMPUTING_UNIT_2.pdf
 
CLOUD_COMPUTING_UNIT_1.pdf
CLOUD_COMPUTING_UNIT_1.pdfCLOUD_COMPUTING_UNIT_1.pdf
CLOUD_COMPUTING_UNIT_1.pdf
 
S16_Notes_CC.pptx
S16_Notes_CC.pptxS16_Notes_CC.pptx
S16_Notes_CC.pptx
 
Asynchronous Frameworks.pptx
Asynchronous Frameworks.pptxAsynchronous Frameworks.pptx
Asynchronous Frameworks.pptx
 
Green computing PPT Notes.ppt
Green computing PPT Notes.pptGreen computing PPT Notes.ppt
Green computing PPT Notes.ppt
 
OOPS(CS8392)_Unit-I_Notes.ppt
OOPS(CS8392)_Unit-I_Notes.pptOOPS(CS8392)_Unit-I_Notes.ppt
OOPS(CS8392)_Unit-I_Notes.ppt
 
Unit-II(STATIC UML DIAGRAMS).ppt
Unit-II(STATIC UML DIAGRAMS).pptUnit-II(STATIC UML DIAGRAMS).ppt
Unit-II(STATIC UML DIAGRAMS).ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docxUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
 
Unit-1_Notes(OOAD).pdf
Unit-1_Notes(OOAD).pdfUnit-1_Notes(OOAD).pdf
Unit-1_Notes(OOAD).pdf
 

Recently uploaded

KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringDr. Radhey Shyam
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationRobbie Edward Sayers
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptxfaamieahmd
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdfKamal Acharya
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdfKamal Acharya
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfAyahmorsy
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxwendy cai
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdfKamal Acharya
 
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfKamal Acharya
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdfAhmedHussein950959
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...Amil baba
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamDr. Radhey Shyam
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdfKamal Acharya
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationDr. Radhey Shyam
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...Amil baba
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdfKamal Acharya
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturingssuser0811ec
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Krakówbim.edu.pl
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsAtif Razi
 

Recently uploaded (20)

KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptx
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 

3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx

  • 1. Input Operations, Arrays, Declarations, Expressions, Statements, Symbolic constant PROGRAMMING IN C
  • 2. Revision •It is possible to utilize an uppercase keyword as an identifier. •Find out whether following are valid identifier. If not why? ◦ 12,245 ◦ 36.0 ◦ 10 20 30 ◦ 123-45-6789 ◦ 0900 PROGRAMMING IN C
  • 3. unsigned and long integer constants PROGRAMMING IN C
  • 4. Average of Three Numbers step 1: Get the input of three real numbers and store in n1,n2, n3 step 2: Calculate Total <- n1 + n2 + n3 step 3: Calculate average <- Total / 3 step 4: Print Total and average PROGRAMMING IN C
  • 5. Simple Interest Calculation ?????????????? PROGRAMMING IN C
  • 6. Simple Interest Calculation #include<stdio.h> int main( ) { int p, n ; float r, si ; p = 1000 ; n = 3 ; r = 8.5 ; si = p * n * r / 100 ; printf ( "%f" , si ) ; } PROGRAMMING IN C
  • 7. Input operations • Input operations are used to read user input from the keyboard • scanf() function is used to read multiple data values of different data types from the keyboard Syntax: scanf(“control string”, arg1, arg2, ………. argn);  Control string (format string) specifies the field format  Arguments arg1, arg2, …, argn specify the address of locations where the data is stored Inputting integer numbers: %d Percentage sign (%) indicates conversion specification, a data type character ( or type specifier) Example: scanf(“%d %d”, &number1, &number2); PROGRAMMING IN C
  • 8. Input operations(cont…) Inputting real numbers: %f Example: scanf(“%f %f”, &number1, &number2); This statement will read the data: 50.35 23.0345 Inputting character strings: %s or %c Example: scanf(“ %s ”, name); This statement will read the data: SASTRA PROGRAMMING IN C
  • 10. Home Work 1)Area of Rectangle 2)Area of Triangle 3)Farenheit to celcius conversion 4)Celcius to Farenheit conversion PROGRAMMING IN C
  • 11. Array An array is an identifier that refers to a collection of data items that all have the same name. The data items must all be of the same type The individual array elements are distinguished from one another by the value that is assigned to a subscript. Example x is a 10-element array. ◦ The first element is referred to as x [ 0J ,the second as x [ 1J ,and so on. ◦ The last element will be x [9J . If the array contains n elements, the subscript will be an integer quantity whose values range from 0 to n-1 . PROGRAMMING IN C
  • 12. Array (Cont….) n-character string will require an (n+l )-element array, because of the null character (O) that is automatically placed at the end of the string. PROGRAMMING IN C
  • 13. Declarations A declaration associates a group of variables with a specific data type. All variables must be declared before they can appear in executable statements It consists of a data type, followed by one or more variable names, ending with a semicolon PROGRAMMING IN C
  • 14. Declarations (Cont…) Initial values can be assigned to variables within a type declaration PROGRAMMING IN C
  • 15. EXPRESSIONS An expression represents a single data item, such as a number or a character. It may consist of a single entity, such as a constant, a variable, an array element or a reference to a function. It may also consist of some combination of such entities, interconnected by one or more operators. It can also represent logical conditions that are either true or false true and false are represented by the integer values 1 and 0, respectively.  Examples are shown there PROGRAMMING IN C
  • 16. STATEMENTS A statement causes the computer to carry out some action. Three different classes ◦ expression statements ◦ compound statements and ◦ control statements Expression Statement o consists of an expression followed by a semicolon. o Several expression statements are shown below. o a = 3; o c = a + b ; o ++i; o p r i n t f ("Area = %f area) ; PROGRAMMING IN C
  • 17. STATEMENTS(cont..) Compound statement ◦ A compound statement consists of several individual statements enclosed within a pair of braces { }. ◦ a compound statement does not end with a semicolon ◦ A typical compound statement is shown below. { p i = 3.141593; circumference = 2. * p i * radius; area = p i * radius * radius; } Control Statement Control statements are used to create special program features, such as logical tests, loops and branches. PROGRAMMING IN C
  • 18. STATEMENTS(cont..) Example while (count <= n) { p r i n t f ( ' x = ' ) ; scanf ( "Skf" , &x) ; sum += x; ++count; } PROGRAMMING IN C
  • 19. Symbolic Constants A symbolic constant is a name that substitutes for a sequence of characters. The characters may represent a numeric constant, a character constant or a string constant. Thus, a symbolic constant allows a name to appear in place of those constant When a program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character sequence. It usually defined at the beginning of a program typically written in uppercase letters does not end with a semicolon PROGRAMMING IN C
  • 20. Symbolic Constants(contd…) Examples #define TAXRATE 0.23 #define P I 3.141593 #define TRUE 1 #define FALSE 0 #define FRIEND "Susan“ Scenario 1 area = PI * radius * radius; statement will become area = 3.141593 * radius * radius; PROGRAMMING IN C
  • 21. Symbolic Constants(contd…) Scenario2 #define CONSTANT 6.023E23 …… …. p r i n t f ( "CONSTANT = %f “,CONSTANT) ; ...... ...... p r i n t f statement would become p r i n t f ( "CONSTANT = %f 6.023E23) ; , during the compilation process. Advantage readily identified than the information that they represent easier to change the value of a single symbolic constant than to change every occurrence of some numerical constant that may appear in several places within the program. PROGRAMMING IN C