Thursday, 17 November 2016

Array with structure


      Structure may consist of one or more arrays as its elements. As we know when we need to store list of elements, then we can use array. In this case the elements of structures of a specified type.

Example of arrays of structure:

struct student
{

int marks[6];

long rollno;

} s;

In above example structure student it contains one arrays as structure member marks. Where it can store the marks of 6 students.

Program:- 





























Output:






Write a program to calculate area of circle with structure and function

Coding:-
                      Structure can be used with the functions in c++ by passing whole structure as an argument to a function.









Output:- 
   




Saturday, 5 November 2016

Operators in C++

Operator:- 
               An Operator is a symbol that specifies an operation to be performed.These operators are used in different combinations to form expressions. For example "+ " is a addition operator that add two digits. The data items on which the operators act upon are called operands.

There are a list of operators in c++ programming language.

- Assignment operator.
- Arithmetic operator.
- Relation operator.
- Logical operator.
-Increment - Decrement operator.


1:- Assignment operator:-

                                                    " =" symbol is known as assignment operator. Assignment operator is used to assign a value to any variable.For example. " a=5". mean 5 is assign to a variable or value of a is now 5.

2:- Arithmetic operator :-   
       
                                            Arithmetic operator are used to perform arithmetic operation. simple mathematical operation comes under this operator like subtraction, addition, multiplication, and division. Various symbol under arithmetic operation are:-


         
Symbol
Meaning
Example
+
Addition
a+b  (2+2)
-
Subtraction
a-b   (2-2)
*
Multiplication
a*b  (2*2)
/
Division
a/b  (2/2)
%
Modulus/ Reminder
a%b (2%2)


  These are five symbol under arithmetic operator in which "+" symbol is used to add to operands like in example  [2+2 =4]. Subtraction "-" used to subtract two operands for example [2-2=0]. Multiplication [*] used to multiply two operands for example [2*2= 4]. Division [/] is to divide two operands for example [2/2=1].Modulus or reminder operator "%" provides reminder. for example [2%2=0].  

3:-Relation Operator:-
                                        The relation operator is used for comparison between two or more operands.It check the relation between two operands.




Symbol
Meaning
Example
< 
Less then
a<b
> 
Greater then
a>b
<=
Less then equal to
a<=b
>=
Greater then equal to
a>=b
==
Equal to
a==b
!=
Not equal to
a!=b




4:- Logical operator:- 
                                        The logical operator are used to compare the one or more Boolean expression and return the result in Boolean. C++ provide following Logical operator:-

                                 &&              (AND)

                                   ||                 (OR)

                                   !                 (NOT)

                 The result of the comparison is either TRUE (1) or FALSE (0).

5:-Increment and Decrement operator:-

                                                                         In c++ , the other unary operator are ++(increment operator) and --(Decrement operator). These operates only one one operands. the ++ and -- operators here have been written after the variable they apply to, in which case they are called the post increment  and post decrement operators. there are also pre increment and pre decrement operator.       
                     Increment operator (++) increase the value of variable by 1.
                     Decrement operator(--) decreases the value of a variable by 1.