Skip to main content

Posts

clkmein.com/wCB07O

clkmein.com/wCB07O
Recent posts

Constants

Defination:              A quantity that cannot change its value during execution of the program is called constant. explanation:             constants are the expressions which have fixed value.constants  are generally categorized into: Literal,Boolean and symbolic constants.They are used to express particular values within the source code of a program.There are four types of constants in C++.These are: integer constants floating point constants character constants string constants Integer Constants:                             A numerical value without a decimal part is called integer constants.The plus(+) and minus(-) sings can also be used with an integer constants.Integer constants are used in expressions for calculations.To print an integer constants,it is given in the output statement without quotation marks.For example to print integer constants 220 and 130,the output statements is written as:                               cout<<220;              

Programs

write a program to assign values to different  variables at the time of declaration.print the assigned values on the computer screen. #include<iostream> using namespace std; main() {        int  xy=1,z=1995;       float ab=3.8;       char name[15]="MOMINA ELAHI";       cout<<name<<endl;       cout<<xy<<endl;       cout<<z<<endl;       cout<<ab<<endl; } Output of the above program MOMINA ELAHI 1 1995 3.8

Programs

PROGRAM 1: #include<iostream> using namespace std; int main() {    cout<<"HELLO WORLD";    return 0; } OUTPUT OF THE PROGRAM: HELLO WORLD                 ............................................................................................................................. PROGRAM 2: #include<iostream> using namespace std; int main() {    cout<<"c++ is best language";    return 0; } OUTPUT OF THE PROGRAM: c++ is best language      .............................................................................................................................                    

Initialization Of Variables

Initialization Of Variables:   When a variable is declared,a memory location is assigned to it.The value in that memory location is  also assigned to the variable.This preassigned value of a variable,if not used by mistake,may result in incorrect result.To avoid this situation, a known value is  assigned to the variable.This value is assigned to the variable at the time of its declaration.Assigning a known value to a variable at the time of its declaration is called initializing of the variable.        For example, to declare variables a,b and c of integer type and assigning values a=220 and b=70,the statement is written as:            int a=220,b=70,c;

Declaration Of Variables

Declaration Of Variables:                                              Assigning the name and data typ e that a variable can hold is called declaration of the variable.All variables that are used in a program are declared using variable declaration statement.              The syntax to declare a variable in c++ is:               type list of variables; where type:          specifies data type of variables.For example,it may be int,float ,etc. list of variables:                        specifies a list of variables separated by commas. In a single statement more than one variables,separated by commas, of same data type can b declared.                                             Different statements are used to declare variables of different data type.                       For example, to declare variables"abc","xyz","w"and "A" of integer   type  the statement is written as:        int abc ,xyz ,d w,A;      To declare var