SlideShare a Scribd company logo
Dale RobertsDale Roberts
Department of Computer and Information Science,
School of Science, IUPUI
A First C Program
Dale Roberts
#include <stdio.h> /* I/O header file */
main()
{
printf(“Hello world ”);
printf(“Welcome to CSCI230n“);
printf(“I am John Smithn”);
}
 A C program contains one or more functions
 main() is the function name of your main (root) program
 { }: braces (left & right) to construct a block containing the statements of a
function
 Every statement must end with a ;
  is called an escape character
 n is an example of an escape sequence which indicates newline
 Other escape sequences are: t r a  ”
Exercise: Use any editor to type and then save your first program as main.c
% gcc main.c
% a.out and observe its result.
header file – contains I/O routines
pre-processor directive
one statement
main must be present in each C program
statement terminator
Indicates a
program
building
block called
function
comment
Dale Roberts
 Variable identifiers
 Begin with a letter or underscore: A-Z, a-z, _
 The rest of the name can be letters, underscore, or digits
 Guarantee that east least the first 8 characters are significant (those
come after the 8th character will be ignored) while most of C compiler
allows 32 significant characters.
Example:
_abc ABC Time time _a1 abcdefgh
abcdefghi (may be the same as abcdefgh)
 Case sensitive
 Keywords: reserved names (lexical tokens)
auto double if static break else int struct
case entry long switch char extern register
typedef float return union do go sizeof continue
…
Dale Roberts
 Four Data Types (assume 2’s complement, byte machine)
Data Type Abbreviation Size
(byte)
Range
char char 1 -128 ~ 127
unsigned char 1 0 ~ 255
int
int 2 or 4 -215
~ 215
-1 or -231
~ 231
-1
unsigned int unsigned 2 or 4 0 ~ 65535 or 0 ~ 232
-1
short int short 2 -32768 ~ 32767
unsigned short int unsigned short 2 0 ~ 65535
long int long 4 -231
~ 231
-1
unsigned long int unsigned long 4 0 ~ 232
-1
float 4
double 8
Note: 27
= 128, 215
=32768, 231
= 2147483648
Complex and double complex are not available
Dale Roberts
type v1,v2,v3, …, vn
Example:
int i;
int j;
float k;
char c;
short int x;
long int y;
unsigned int z;
int a1, a2, a3, a4, a5;
Dale Roberts
 Literal
 Numeric literal
 fixed-point
 octal O32 (= 24D) (covered later)
 hexadecimal OxFE or Oxfe (=254D) (covered later)
 decimal int 32
 long (explicit) 32L or 32l
 an ordinary integer literal that is too long to fit in an int is
also too long for long
 floating-point
 No single precision is used; always use double for literal
Example:
1.23
123.456e-7
0.12E
Dale Roberts
• Character literal (covered later)
•American Standard Code for Information Interchange (ASCII)
•Printable: single space 32
‘0’ - ‘9’ 48 - 57
‘A’ - ‘Z’ 65 - 90
‘a’ - ‘z’ 97 - 122
•Nonprintable and special meaning chars
‘n’ new line 10 ‘t’ tab 9
‘’ back slash 9 ‘’’ single quote 39
‘0’ null 0 ‘b’ back space 8
‘f’ formfeed 12 ’r’ carriage return 13
‘”’ double quote 34
‘ddd’ arbitrary bit pattern using 1-3 octal digits
‘Xdd’ for Hexadecimal mode
‘017’ or ‘17’ Shift-Ins, ^O
‘04’ or ‘4’ or ‘004’ EOT (^D)
‘033’ or ‘X1B’ <esc>
Dale Roberts
 String Literal
 will be covered in Array section
 String is a array of chars but ended by ‘0’
 String literal is allocated in a continuous memory
space of Data Segment, so it can not be rewritten
Example: “ABCD”
...A B C D ‘0’
Ans: 13+1 = 14 bytes
Question: “I am a string” takes ? Bytes
4 chars but takes 5 byte spaces in memory
Dale Roberts
• Character literals & ASCII codes:
char x;
x=‘a’; /* x = 97*/
Notes:
–‘a’ and “a” are different; why?
‘a’ is the literal 97
“a” is an array of character literals, { ‘a’, ‘0’} or {97, 0}
–“a” + “b” +”c” is invalid but ‘a’+’b’+’c’ = ? (hint: ‘a’ = 97 in ASCII)
–if the code used is not ASCII code, one should check out each
value of character
1 38
‘a’ + ‘b’ + ‘c’ = 97 + 98 + 99 = 294 = 256 + 38
in the memory
Dale Roberts
 If a variable is not initialized, the value of
variable may be either 0 or garbage depending
on the storage class of the variable.
int i=5;
float x=1.23;
char c=‘A’;
int i=1, j,k=5;
char c1 = ‘A’, c2 = 97;
float x=1.23, y=0.1;
Dale Roberts
 Each variable has a name, address, type, and value
1) int x;
2) scanf(“%d”, &x);
3) user inputs 10
4) x = 200;
After the execution of (1) x
After the execution of (2) x
After the execution of (3) x
After the execution of (4) x
Previous value of x was overwritten
10
200
Dale Roberts
 Write a program to take two numbers as input data
and print their sum, their difference, their product and
their quotient.
Problem Inputs
float x, y; /* two items */
problem Output
float sum; /* sum of x and y */
float difference; /* difference of x and y */
float product; /* product of x and y */
float quotient; /* quotient of x divided by
y */
Dale Roberts
 Pseudo Code:
Declare variables of x and y;
Prompt user to input the value of x and y;
Print the sum of x and y;
Print the difference of x and y;
Print the product of x and y;
If y not equal to zero, print the quotient of x divided
by y
Dale Roberts
#include <stdio.h>
int main(void)
{
float x,y;
float sum;
printf(“Enter the value of x:”);
scanf(“%f”, &x);
printf(“nEnter the value of y:”);
scanf(“%f”, &y);
sum = x + y;
printf(“nthe sum of x and y is:%f”,sum);
printf(“nthe sum of x and y is:%f”,x+y);
printf(“nthe difference of x and y is:%f”,x-y);
printf(“nthe product of x and y is:%f”,x*y);
if (y != 0)
printf(“nthe quotient of x divided by y is:%f”,x/y);
else
printf(“nquotient of x divided by y does not
exist!n”);
return(0);
}
function
• name
• list of argument along with their types
• return value and its type
• Body
inequality operator

More Related Content

What's hot

Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
shashikant pabari
 
C++
C++C++
C++ Basics
C++ BasicsC++ Basics
C++ Basics
Himanshu Sharma
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
Steve Johnson
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
jatin batra
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
Eelco Visser
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
Basic of c &c++
Basic of c &c++Basic of c &c++
Basic of c &c++
guptkashish
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala
jatin batra
 
C++ Language
C++ LanguageC++ Language
C++ Language
Vidyacenter
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
Way2itech
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
Ameer Khan
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
C++
C++C++
C++k v
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
Hossein Zahed
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
ASIT
 

What's hot (20)

Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
C++
C++C++
C++
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
Basic of c &c++
Basic of c &c++Basic of c &c++
Basic of c &c++
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
C++
C++C++
C++
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
 

Viewers also liked

전망좋은펜션『BU797』.『COM』제주여행싸게가기
전망좋은펜션『BU797』.『COM』제주여행싸게가기전망좋은펜션『BU797』.『COM』제주여행싸게가기
전망좋은펜션『BU797』.『COM』제주여행싸게가기
hdflkgjdo
 
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...Tanay Kumar Das
 
ApresentaçãO Primeira AudiêNcia 1
ApresentaçãO Primeira AudiêNcia 1ApresentaçãO Primeira AudiêNcia 1
ApresentaçãO Primeira AudiêNcia 1José Augusto Fiorin
 
외도유람선『LG777』.『XYZ』하이원
외도유람선『LG777』.『XYZ』하이원외도유람선『LG777』.『XYZ』하이원
외도유람선『LG777』.『XYZ』하이원
hdflkgjdo
 
CIDCO Estate Management Software new
CIDCO Estate Management Software newCIDCO Estate Management Software new
CIDCO Estate Management Software newFaiyaz Khan
 
마녀사냥
마녀사냥마녀사냥
마녀사냥
hdflkgjdo
 
Css
Css Css
Present to influence - October 2013
Present to influence - October 2013Present to influence - October 2013
Present to influence - October 2013Joni Axon
 
Introduction to ASP .Net
Introduction to ASP .NetIntroduction to ASP .Net
Introduction to ASP .Netayman diab
 
Få succes med Social Selling
Få succes med Social SellingFå succes med Social Selling
Få succes med Social Selling
Business Danmark
 
Salgstrends 2017
Salgstrends 2017  Salgstrends 2017
Salgstrends 2017
Business Danmark
 
Introduction to asp .net
Introduction to asp .netIntroduction to asp .net
Introduction to asp .net
umesh patil
 
Hacemos escalada5 ºb
Hacemos escalada5 ºbHacemos escalada5 ºb
Hacemos escalada5 ºb
Puy Mateo
 
Miercoles
MiercolesMiercoles
Miercoles
Puy Mateo
 
El quijote cía
El quijote cíaEl quijote cía
El quijote cía
Puy Mateo
 
Administrasi sekolah ppt
Administrasi sekolah pptAdministrasi sekolah ppt
Administrasi sekolah ppt
Sutoyo Biwi
 
анара мусина+необычный парк+ предпринематели
анара мусина+необычный парк+ предпринемателианара мусина+необычный парк+ предпринематели
анара мусина+необычный парк+ предпринематели
Anara Mussina
 
Y jugamos
Y jugamosY jugamos
Y jugamos
Puy Mateo
 

Viewers also liked (18)

전망좋은펜션『BU797』.『COM』제주여행싸게가기
전망좋은펜션『BU797』.『COM』제주여행싸게가기전망좋은펜션『BU797』.『COM』제주여행싸게가기
전망좋은펜션『BU797』.『COM』제주여행싸게가기
 
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...
Ssc stenographer grade c & d exam 2012 coaching at cheap rate with free study...
 
ApresentaçãO Primeira AudiêNcia 1
ApresentaçãO Primeira AudiêNcia 1ApresentaçãO Primeira AudiêNcia 1
ApresentaçãO Primeira AudiêNcia 1
 
외도유람선『LG777』.『XYZ』하이원
외도유람선『LG777』.『XYZ』하이원외도유람선『LG777』.『XYZ』하이원
외도유람선『LG777』.『XYZ』하이원
 
CIDCO Estate Management Software new
CIDCO Estate Management Software newCIDCO Estate Management Software new
CIDCO Estate Management Software new
 
마녀사냥
마녀사냥마녀사냥
마녀사냥
 
Css
Css Css
Css
 
Present to influence - October 2013
Present to influence - October 2013Present to influence - October 2013
Present to influence - October 2013
 
Introduction to ASP .Net
Introduction to ASP .NetIntroduction to ASP .Net
Introduction to ASP .Net
 
Få succes med Social Selling
Få succes med Social SellingFå succes med Social Selling
Få succes med Social Selling
 
Salgstrends 2017
Salgstrends 2017  Salgstrends 2017
Salgstrends 2017
 
Introduction to asp .net
Introduction to asp .netIntroduction to asp .net
Introduction to asp .net
 
Hacemos escalada5 ºb
Hacemos escalada5 ºbHacemos escalada5 ºb
Hacemos escalada5 ºb
 
Miercoles
MiercolesMiercoles
Miercoles
 
El quijote cía
El quijote cíaEl quijote cía
El quijote cía
 
Administrasi sekolah ppt
Administrasi sekolah pptAdministrasi sekolah ppt
Administrasi sekolah ppt
 
анара мусина+необычный парк+ предпринематели
анара мусина+необычный парк+ предпринемателианара мусина+необычный парк+ предпринематели
анара мусина+необычный парк+ предпринематели
 
Y jugamos
Y jugamosY jugamos
Y jugamos
 

Similar to C language

C language first program
C language first programC language first program
C language first program
NIKHIL KRISHNA
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogramprincepavan
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
Saifur Rahman
 
C tutorial
C tutorialC tutorial
C tutorial
Anurag Sukhija
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
Sami Said
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
Verilogspk1
Verilogspk1Verilogspk1
Verilogspk1
supriya kurlekar
 
C programming language
C programming languageC programming language
C programming language
Mahmoud Eladawi
 
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
DinobandhuThokdarCST
 
AssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docxAssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docx
ssuser562afc1
 
Cpprm
CpprmCpprm
Cpprm
Shawne Lee
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
SyedAzim6
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 

Similar to C language (20)

C language first program
C language first programC language first program
C language first program
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
First c program
First c programFirst c program
First c program
 
C tutorial
C tutorialC tutorial
C tutorial
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
Verilogspk1
Verilogspk1Verilogspk1
Verilogspk1
 
C programming language
C programming languageC programming language
C programming language
 
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
 
AssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docxAssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docx
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
Cpprm
CpprmCpprm
Cpprm
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Cbasic
CbasicCbasic
Cbasic
 
Cbasic
CbasicCbasic
Cbasic
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 

More from umesh patil

Ccna security
Ccna security Ccna security
Ccna security
umesh patil
 
Array in c language
Array in c languageArray in c language
Array in c language
umesh patil
 
Array in c language
Array in c language Array in c language
Array in c language
umesh patil
 
Jquery Preparation
Jquery PreparationJquery Preparation
Jquery Preparation
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
umesh patil
 
C language
C language C language
C language
umesh patil
 
Html and css presentation
Html and css presentationHtml and css presentation
Html and css presentation
umesh patil
 
Html Presentation
Html PresentationHtml Presentation
Html Presentation
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
umesh patil
 
Java script
Java scriptJava script
Java script
umesh patil
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 
Php vs asp
Php vs aspPhp vs asp
Php vs asp
umesh patil
 
Ccna security
Ccna security Ccna security
Ccna security
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Array in c language
Array in c language Array in c language
Array in c language
umesh patil
 

More from umesh patil (20)

Ccna security
Ccna security Ccna security
Ccna security
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Array in c language
Array in c language Array in c language
Array in c language
 
Jquery Preparation
Jquery PreparationJquery Preparation
Jquery Preparation
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
 
C language
C language C language
C language
 
Html and css presentation
Html and css presentationHtml and css presentation
Html and css presentation
 
Html Presentation
Html PresentationHtml Presentation
Html Presentation
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
 
Java script
Java scriptJava script
Java script
 
Function in c program
Function in c programFunction in c program
Function in c program
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
 
Php vs asp
Php vs aspPhp vs asp
Php vs asp
 
Ccna security
Ccna security Ccna security
Ccna security
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Array in c language
Array in c language Array in c language
Array in c language
 

Recently uploaded

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

C language

  • 1. Dale RobertsDale Roberts Department of Computer and Information Science, School of Science, IUPUI A First C Program
  • 2. Dale Roberts #include <stdio.h> /* I/O header file */ main() { printf(“Hello world ”); printf(“Welcome to CSCI230n“); printf(“I am John Smithn”); }  A C program contains one or more functions  main() is the function name of your main (root) program  { }: braces (left & right) to construct a block containing the statements of a function  Every statement must end with a ;  is called an escape character  n is an example of an escape sequence which indicates newline  Other escape sequences are: t r a ” Exercise: Use any editor to type and then save your first program as main.c % gcc main.c % a.out and observe its result. header file – contains I/O routines pre-processor directive one statement main must be present in each C program statement terminator Indicates a program building block called function comment
  • 3. Dale Roberts  Variable identifiers  Begin with a letter or underscore: A-Z, a-z, _  The rest of the name can be letters, underscore, or digits  Guarantee that east least the first 8 characters are significant (those come after the 8th character will be ignored) while most of C compiler allows 32 significant characters. Example: _abc ABC Time time _a1 abcdefgh abcdefghi (may be the same as abcdefgh)  Case sensitive  Keywords: reserved names (lexical tokens) auto double if static break else int struct case entry long switch char extern register typedef float return union do go sizeof continue …
  • 4. Dale Roberts  Four Data Types (assume 2’s complement, byte machine) Data Type Abbreviation Size (byte) Range char char 1 -128 ~ 127 unsigned char 1 0 ~ 255 int int 2 or 4 -215 ~ 215 -1 or -231 ~ 231 -1 unsigned int unsigned 2 or 4 0 ~ 65535 or 0 ~ 232 -1 short int short 2 -32768 ~ 32767 unsigned short int unsigned short 2 0 ~ 65535 long int long 4 -231 ~ 231 -1 unsigned long int unsigned long 4 0 ~ 232 -1 float 4 double 8 Note: 27 = 128, 215 =32768, 231 = 2147483648 Complex and double complex are not available
  • 5. Dale Roberts type v1,v2,v3, …, vn Example: int i; int j; float k; char c; short int x; long int y; unsigned int z; int a1, a2, a3, a4, a5;
  • 6. Dale Roberts  Literal  Numeric literal  fixed-point  octal O32 (= 24D) (covered later)  hexadecimal OxFE or Oxfe (=254D) (covered later)  decimal int 32  long (explicit) 32L or 32l  an ordinary integer literal that is too long to fit in an int is also too long for long  floating-point  No single precision is used; always use double for literal Example: 1.23 123.456e-7 0.12E
  • 7. Dale Roberts • Character literal (covered later) •American Standard Code for Information Interchange (ASCII) •Printable: single space 32 ‘0’ - ‘9’ 48 - 57 ‘A’ - ‘Z’ 65 - 90 ‘a’ - ‘z’ 97 - 122 •Nonprintable and special meaning chars ‘n’ new line 10 ‘t’ tab 9 ‘’ back slash 9 ‘’’ single quote 39 ‘0’ null 0 ‘b’ back space 8 ‘f’ formfeed 12 ’r’ carriage return 13 ‘”’ double quote 34 ‘ddd’ arbitrary bit pattern using 1-3 octal digits ‘Xdd’ for Hexadecimal mode ‘017’ or ‘17’ Shift-Ins, ^O ‘04’ or ‘4’ or ‘004’ EOT (^D) ‘033’ or ‘X1B’ <esc>
  • 8. Dale Roberts  String Literal  will be covered in Array section  String is a array of chars but ended by ‘0’  String literal is allocated in a continuous memory space of Data Segment, so it can not be rewritten Example: “ABCD” ...A B C D ‘0’ Ans: 13+1 = 14 bytes Question: “I am a string” takes ? Bytes 4 chars but takes 5 byte spaces in memory
  • 9. Dale Roberts • Character literals & ASCII codes: char x; x=‘a’; /* x = 97*/ Notes: –‘a’ and “a” are different; why? ‘a’ is the literal 97 “a” is an array of character literals, { ‘a’, ‘0’} or {97, 0} –“a” + “b” +”c” is invalid but ‘a’+’b’+’c’ = ? (hint: ‘a’ = 97 in ASCII) –if the code used is not ASCII code, one should check out each value of character 1 38 ‘a’ + ‘b’ + ‘c’ = 97 + 98 + 99 = 294 = 256 + 38 in the memory
  • 10. Dale Roberts  If a variable is not initialized, the value of variable may be either 0 or garbage depending on the storage class of the variable. int i=5; float x=1.23; char c=‘A’; int i=1, j,k=5; char c1 = ‘A’, c2 = 97; float x=1.23, y=0.1;
  • 11. Dale Roberts  Each variable has a name, address, type, and value 1) int x; 2) scanf(“%d”, &x); 3) user inputs 10 4) x = 200; After the execution of (1) x After the execution of (2) x After the execution of (3) x After the execution of (4) x Previous value of x was overwritten 10 200
  • 12. Dale Roberts  Write a program to take two numbers as input data and print their sum, their difference, their product and their quotient. Problem Inputs float x, y; /* two items */ problem Output float sum; /* sum of x and y */ float difference; /* difference of x and y */ float product; /* product of x and y */ float quotient; /* quotient of x divided by y */
  • 13. Dale Roberts  Pseudo Code: Declare variables of x and y; Prompt user to input the value of x and y; Print the sum of x and y; Print the difference of x and y; Print the product of x and y; If y not equal to zero, print the quotient of x divided by y
  • 14. Dale Roberts #include <stdio.h> int main(void) { float x,y; float sum; printf(“Enter the value of x:”); scanf(“%f”, &x); printf(“nEnter the value of y:”); scanf(“%f”, &y); sum = x + y; printf(“nthe sum of x and y is:%f”,sum); printf(“nthe sum of x and y is:%f”,x+y); printf(“nthe difference of x and y is:%f”,x-y); printf(“nthe product of x and y is:%f”,x*y); if (y != 0) printf(“nthe quotient of x divided by y is:%f”,x/y); else printf(“nquotient of x divided by y does not exist!n”); return(0); } function • name • list of argument along with their types • return value and its type • Body inequality operator