0% found this document useful (0 votes)
60 views5 pages

The C Command Symbols

pROGRAMMING IN C LANGUAGE

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views5 pages

The C Command Symbols

pROGRAMMING IN C LANGUAGE

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

The C command symbols / *, * / are still valid and are more suitable for multiline

.comments
: The following comment is allowed

/ * This is example of C++ program to illustrate some of its features * /

-: Output operators

The statement
;"Cout<<"C++ is better then C
causes the string in quotation marks to be displayed on the screen. The identifier cout
is a predefined object the represents the standard O/P stream in C++ . Here,the
.standard O/P stream in C++ represents the screen
.The operator << is called the insertion or put to operation

The iostream.h File

: We have used the foll #include directive in program


>include <iostream.h#
This directive causes the preprocessor to add the contents of the file iostream.h to the
. << program . it contains declarations for the identifier cout and the operator

.WAP to read 2 nos & display their average on the screen . 2

>include<iostream.h#
) (Main
{
; Float number1 , number2 , sum , avg
;Cout<<"enter 2 nos = " //prompt
Cin>>number1; / /read numbers
Cin>>number2;// from keyboard
;Sum = number1+number2
; Avg = sum/2
; "Cout<<"sum = "<<sum<<"\n
;Cout<<"average = "<<avg
}

: The output of program

Enter 2 nos : 68 7.5


Sum = 14
Average = 7

Input operators
: The statement
; Cin>>number1
Is an i/p statement and causes the program to wait for the user to type in a no . the
number keyed in is placed in the variable number1. the identifier cin is a predefined
object in c++ that corresponds to the standard i/p stream . here , this stream represent
. the keyboard
. WAP to find area and circumference of a circle . 3

>include<iostream.h#
>include<conio.h#
) (Void main
{
;) (Clrscr
; Float r , area , circum
;" Cout<<"enter radius of circle
; Cin>>r
; Area = 3.14 *r * r
; Cout<<"\n area = "<<area
; Circum =2 * 3.14 * r
; Cout<<"circumference = "<<circum
}

.WAP to find area and perimeter of a rectangle . 4

>include<iostream.h#
>include<conio.h#
) (Void main
{
;) (Clrscr
; Float l , w , area, peri
: Cout<<"enter length and width of rect
Cin >>l >>w ; // aceepting length and width of a rect
;Area = l*w
; Peri = 2 * (l*w)
; Cout<<"\n area = "<<area<<" \n perimeter = "<<perimeter
}

.WAP to convert temperature in Fahrenheit equivalent of centigrade .5

>include<iostream.h#
>include<conio.h#
) (Void main
{
; ) ( Clrscr
; Float cen , faren
;" Cout<<"input temp in centigrade
; Cin >>cen
; Faren =1.8*cen +32
; Cout<<"\n equivalent farenheit temp is : "<<faren
}
Structure of a program

: Basic Data Types

Type Bytes Range

Char 1 -128 to 127 .1


Int 2 -32768 to 32767 .2
Float 4 3.4E-38 to 3.4E+38 .3
Double 8 1.7E-308 to 1.7E+308 .4
: Tokens

The smallest individual units in a program are known as tokens . C++ has the foll
-: tokens

Keywords . 1
Identifiers . 2
Constants .3
Strings .4
Operators .5

-: Keywords . 1
The keywords implement specific c++ language features .They are explicitly
reserved identifiers and cannot be used as names for the program variables or other
. user-defined program elements

Asm double new switch


Auto else operator template
Break enum private this
Case extern protected throw
Catch float public try

Identifiers . 2

Identifiers refer to the names of variables, functions, arrays, classes, etc created
by the programmer. They are the fundamental requirement of any language. Each
.language has its own rules for naming these identifiers
++The foll rules are common to both C and C

.Only alphabetic characters, digits and underscores are permitted .1


.The name cannot start with a digit .2
.Uppercase and lowercase letters are distinct .3
.A declared keyword cannot be used as a variable name .4

Symbolic Constants . 3

.We can declare constant using qualifier constant


;Eg: const int size =10
It is equal to
;Const size = 10

++Operators in C . 4

Scope resolution operator ::


pointer-to-member declarator *::
pointer-to-member operator *>-
pointer-to-member operator *.
Delete memory release operator
Endl line feed operator
New memory allocation operator
Setw field width operator
OBJECT – ORIENTED LANGUAGES

Object-oriented programming is not the right of any particular language . Like


structured programming, OOP concepts can be implemented using languages such as C
and pascal .However, programming becomes clumsy and may generate confusion when
programs grow large. A language that is specially designed to support the OOP
.concepts makes it easier to implement them
Depending upon the features they support, they can be classified into the following
-:2 categories
Object - based programming languages .1
Object – oriented programming languages .2

Object –based programming languages . 1

. Object based language primarily support encapsulation and object identity


- : Major features that are required for object based programming are

Data encapsulation .1
Data hiding and access mechanism .2
Automatic initialization and clear up of objects .3
Operator overloading .4

Languages that support programming with objects are said to be object based
.programming languages. They do not support inheritance and dynamic binding
.Ada is a typical object-based programming language

Object – oriented programming language . 2

Object-oriented programming language incorporates all object based features along


.with 2 additional features, like inheritance and dynamic binding

OOP = Object-based features + Inheritance +Dynamic binding

.The language that support features include C++, small talk and object pascal

You might also like