This document provides an introduction to C++ programming including problem solving skills, software evolution, procedural and object oriented programming concepts, basic C++ programs, operators, header files, conditional statements, loops, functions, pointers, structures and arrays. It discusses topics such as analyzing problems, planning algorithms, coding solutions, evaluating results, procedural and object oriented paradigms, inheritance, polymorphism, flowcharts, basic syntax examples, and more. Various examples are provided to illustrate key concepts in C++.
Algorithm and C code related to data structureSelf-Employed
Everything lies inside an algorithm in the world of coding and algorithm formation which is the basis of data structure and manipulation of the algorithm in computer science and information technology which is ultimately used to find a particular problems solution
Algorithm and C code related to data structureSelf-Employed
Everything lies inside an algorithm in the world of coding and algorithm formation which is the basis of data structure and manipulation of the algorithm in computer science and information technology which is ultimately used to find a particular problems solution
The sole purpose of sharing these slides are to educate the beginners of IT and Computer Science/Engineering. Credits should go to the referred material and also CICRA campus, Colombo 4, Sri Lanka where I taught these in 2017.
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
The sole purpose of sharing these slides are to educate the beginners of IT and Computer Science/Engineering. Credits should go to the referred material and also CICRA campus, Colombo 4, Sri Lanka where I taught these in 2017.
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
2. Problem Solving Skills
• STEP 1: ANALYSE THE PROBLEM
• STEP 2: PLANNING THE ALGORITHM
• STEP 3: CHECK THE ALGORITHM
• STEP 4: CODING THE ALGORITHM
• STEP 5: EVALUATE AND MODIFY
10. Problem solving skills
• Step 1: Understanding the Problem:
• Here we try to understand the problem to be solved in totally. Before with the next stage
or step, we should be absolutely sure about the objectives of the given problem.
• Step 2: Analyzing the Problem:
• After understanding thoroughly the problem to be solved, we look at different ways of
solving the problem and evaluate each of these methods.
• The idea here is to search for an appropriate solution to the problem under
consideration. The end result of this stage is a broad overview of the sequence of
operations that are to be carried out to solve the given problem.
• Step 3: Developing the solution:
• Here, the overview of the sequence of operations that was the result of the analysis
stage is expanded to form a detailed step by step solution to the problem under
consideration.
11. Problem solving skills
• Step 4: Coding and Implementation:
• The last stage of problem-solving is the conversion of the detailed sequence of operations into a language
that the computer can understand. Here, each step is converted to its equivalent instruction or instructions
in the computer language that has been chosen for the implantation.
• The vehicle for the computer solution to a problem is a set of explicit and unambiguous instructions
expressed in a programming language. This set of instruction is called a program with problem solving
through programming in C++.
• A program may also be thought of as an algorithm expressed in a programming language. an algorithm,
therefore, corresponds to a solution to a problem that is independent of any programming language.
• To obtain the computer solution to a problem once we have the program we usually have to supply the
program with input or data. The program then takes this input and manipulates it according to its
instructions. Eventually produces an output which represents the computer solution to the problem.
• The problem solving is a skill and there are no universal approaches one can take to solving problems.
Basically one must explore possible avenues to a solution one by one until she/he comes across the right
path to a solution.
• In general, as one gains experience in solving problems, one develops one’s own techniques and strategies,
though they are often intangible. Problem-solving skills are recognized as an integral component of
computer programming.
15. Pre processor directive
• Nothing but a program
• It makes the C++ program portable
• User can create own pre-processor directive
• Can be placed before the main function
• Cannot be terminated by semi colon since it is a special instruction
• E.g # include – includes the header file (containing library functions)
16. Namespace in C++
• What is a namespace in C++?
• A namespace is a declarative region that provides a scope where
identifiers like variables, functions, classes etc are declared.
• Main purpose is to prevent ambiguity that may occur when two
identifiers have same name.
•
22. If else conditional statement
• Greet according to time of the day
• Check if integer is positive, negative or zero
• Find largest number amongst 3 nos
24. • The switch expression is evaluated once
• The value of the expression is compared with the
values of each case
• If there is a match, the associated block of code is
executed
• The break and default keywords are optional
25. • int day = 4;
switch (day) {
case 1:
cout << "Monday";
break;
case 2:
cout << "Tuesday";
break;
case 3:
cout << "Wednesday";
break;
case 4:
cout << "Thursday";
break;
case 5:
cout << "Friday";
break;
case 6:
cout << "Saturday";
break;
case 7:
cout << "Sunday";
break;
}
26. • Write an algorithm, draw a flowchart and write a C program to accept
the percentage and print the grade A (90 to 100), B (80 to 90), C (50
to 80) and Fail below 50.
• Write a C++ program to check whether input character is vowel or
consonant.
• Write a program to give a choice to user to find area of a shape –
circle, rectangle, triangle, square
38. Nested loop
• do
• {
• do
• {
• // statement of inside loop
• }
• while(condition);
• // statement of outer loop
• }
• while(condition);
39. 2D array
• Write a program to take values for 2-dimensional array and to give
choice to the user for performing below operations:
• 1. Sum of elements of each row.
• 2. Sum of diagonal elements.
• 3. Finding transpose of matrix
40. 2D array
• Develop, implement and execute a C++ program that reads two
matrices A (m x n ) and B (p x q ) and Compute the product A and B.
Read matrix A and matrix B in row major order and in column major
order respectively. Print both the input matrices and resultant matrix
with suitable headings and output should be in matrix format only.
Program must check the compatibility of orders of the matrices for
multiplication. Report appropriate message in case of incompatibility.
41. Functions
1. Write a function to find sum and average of upper diagonal elements
in 2-dimensional matrix. Write a main program () to take number of
rows, cols and values of matrix from the user.
2.Write a menu-based program in C++ (Use Switch case and do while)
that uses a set of functions to perform the following operations:
• a. Addition of two complex numbers
• b. Subtraction of two complex numbers
• c. Multiplication of two complex numbers
42. Inline function example
#include <iostream>
using namespace std;
inline int cube(int s)
{
return s*s*s;
}
int main()
{
cout << "The cube of 3 is: " << cube(3) << "n";
return 0;
}
43. Inline function example
#include <iostream>
using namespace std;
inline int Max(int x, int y)
{ return (x > y)? x : y; }
// Main function for the program
int main() { cout << "Max (20,10): " << Max(20,10) << endl;
cout << "Max (0,200): " << Max(0,200) << endl;
cout << "Max (100,1010): " << Max(100,1010) << endl; return 0; }
44. Some facts about inline function
• Compiler may not perform inlining in such circumstances like:
1) If a function contains a loop. (for, while, do-while)
2) If a function contains static variables.
3) If a function is recursive.
4) If a function return type is other than void, and the return
statement doesn’t exist in function body.
5) If a function contains switch or goto statement.
45. Some facts about inline function
• The added variables from the inlined function consumes additional
registers, After in-lining function if variables number which are going
to use register increases than they may create overhead on register
variable resource utilization. This means that when inline function
body is substituted at the point of function call, total number of
variables used by the function also gets inserted. So the number of
register going to be used for the variables will also get increased. So if
after function inlining variable numbers increase drastically then it
would surely cause an overhead on register utilization.
46. Some facts about inline function
• If you use too many inline functions then the size of the binary
executable file will be large, because of the duplication of same code.
• Too much inlining can also reduce your instruction cache hit rate, thus
reducing the speed of instruction fetch from that of cache memory to
that of primary memory.
47. Structures
struct { // Structure declaration
int myNum; // Member (int variable)
string myString; // Member (string variable)
} myStructure; // Structure variable
• Structures (also called structs) are a way to group several related variables
into one place. Each variable in the structure is known as a member of the
structure.
• Unlike an array, a structure can contain many different data types (int,
string, bool, etc.).
48. Example
• // Create a structure variable called myStructure
struct {
int myNum;
string myString;
} myStructure;
// Assign values to members of myStructure
myStructure.myNum = 1;
myStructure.myString = "Hello World!";
// Print members of myStructure
cout << myStructure.myNum << endl;
cout << myStructure.myString << endl;
49. Example of structure
#include <iostream>
using namespace std;
struct Person
{ char name[50];
int age; float salary; };
int main()
{ Person p1;
cout << "Enter Full name: ";
cin.get(p1.name, 50);
cout << "Enter age: ";
cin >> p1.age;
cout << "Enter salary: ";
cin >> p1.salary;
cout << "nDisplaying Information." << endl;
cout << "Name: " << p1.name << endl;
cout <<"Age: " << p1.age << endl;
cout << "Salary: " << p1.salary; return 0; }
50. Structure as function argument
#include<iostream>
using namespace std;
struct Person
{ int citizenship; int age; };
void func(struct Person p);
int main()
{ struct Person p; p.citizenship = 1; p.age = 27; func(p); return 0; }
void func(struct Person p) { cout << " Person citizenship: " <<
p.citizenship<<endl;
cout << " Person age: " << p.age; }
51. Pointers
• Pointers store the address of variables or a memory location
• pointer “ptr” holds the address of an integer variable or holds the
address of memory whose value(s) can be accessed as integer values
through “ptr”
• Pointers:
• Pointers save memory space.
• Execution time with pointers is faster because data are manipulated
with the address, that is, direct access to memory location.
• Memory is accessed efficiently with the pointers. The pointer assigns
and releases the memory as well. Hence it can be said the Memory of
pointers is dynamically allocated.
• Pointers are used with data structures. They are useful for
representing two-dimensional and multi-dimensional arrays.
52. Pointers
• pointer is a symbolic representation of a memory address.
• Here is an example of valid pointer declarations in C++:
• int *x; // a pointer to integer
• double *x; // a pointer to double
• float *x; // a pointer to float
• char *ch // a pointer to a character
53. Pointers
• Reference operator (&) and Deference operator (*)
• The reference operator (&) returns the variable’s address.
• The dereference operator (*) helps us get the value that has been
stored in a memory address.
54. Example of Pointers
#include <iostream>
using namespace std;
int main()
{ int x = 27;
int *ip;
ip = &x;
cout << "Value of x is : ";
cout << x << endl;
cout << "Value of ip is : ";
cout << ip<< endl;
cout << "Value of *ip is : ";
cout << *ip << endl; return 0; }
55. More examples in Pointers
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int i = 10;
int *Ptr;
Ptr = &i;
cout << "nValue Of i :" << i;
cout << "nAddress Of i :" << i;
cout << "nValue Of Ptr :" << Ptr;
cout << "nAddress Of Ptr :" << &Ptr;
cout << "nPtr's Pointer Value:" << *Ptr;
cout << "nPtr Equal to &i :" << *(&i); }
57. Array using Pointers
#include <iostream>
using namespace std;
int main()
{ int *ip;
int arr[] = { 10, 34, 13, 76, 5, 46 };
ip = arr;
for (int x = 0; x < 6; x++)
{ cout << *ip << endl; ip++; }
return 0; }
58. Functions in Pointers
#include <iostream>
using namespace std;
void test(int*, int*);
int main()
{ int a = 5, b = 5;
cout << "Before changing:" << endl;
cout << "a = " << a << endl;
cout << "b = " << b << endl;
test(&a, &b);
cout << "nAfter changing" << endl;
cout << "a = " << a << endl;
cout << "b = " << b << endl;
return 0; }
void test(int* n1, int* n2)
{ *n1 = 10; *n2 = 11; }
59. Swapping numbers using pointers
#include <iostream>
#include<conio.h>
using namespace std;
// Declare Swap Function Using Pointer
void swap_numbers(int *value1, int *value2)
{ int temp;
temp = *value1;
*value1 = *value2;
*value2 = temp; }
int main()
{ // Declare Variables int number1, number2;
cout << "Simple Example Program for Swap Numbers Using Pointers In C++“<<endl;
// Read User Input
60. Swapping numbers using pointers
//Print Values before Swapping
cout << "Enter value of Swap Number # 1: ";
cin>>number1;
cout << "Enter value of Swap Number # 2: ";
cin>>number2;
cout << "Before Swapping : Number # 1=" << number1 << ", Number # 2=" << number2 <<
endl;
//Call Swap Function By Passing Reference
swap_numbers(&number1, &number2);
//Print Values after Swapping
cout << "After Swapping : Number # 1=" << number1 << ", Number # 2=" << number2 <<
endl;
getch();
return 0; }
61. Print string using pointers
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{ // Declare Variables
char str[20], *pt;
cout << "Pointer Example C++ Program : Print String”<<endl;
cout << "Enter Any string [below 20 chars] : ";
cin>>str;
// Assign to Pointer Variable
pt = str;
while (*pt != '0')
{ cout << *pt;
pt++; }
return 0; }
62. Declaring a Pointer to a pointer
• int *ptr1 = &var; // Declaration of single pointer.
• int **ptr2 = &ptr1; // Declaration of double pointer or pointer to
pointer in C++.
63. Declaring a Pointer to a pointer
#include<iostream>
using namespace std;
int main()
{ // Declaring an integer variable.
int age = 21;
// Declaring a single pointer variable, // storing address of age variable.
int *ptr1 = &age;
// Declaring a double pointer variable storing address of ptr1.
int **ptr2 = &ptr1;
// Printing value using age variable.
cout<<"Value stored in the var variable "<<var<<"n";
// Printing value using single pointer variable.
cout<<"Value accessed using single pointer "<<*ptr1<<"n";
// Printing value using double pointer variable.
cout<<"Value accessed using double pointer "<<**ptr2<<"n";
return 0; }
64.
65.
66. Examples of pointers
• WAP to demonstrate different arithmetic operations on pointers.
• WAP to find largest of the elements of an array using a function and
passing argument using pointer.
• WAP to demonstrate use of a pointer to pointer.
• WAP to demonstrate string handling using pointer.
67.
68. To do Tasks
• WAP to demonstrate different arithmetic operations on pointers.
• WAP to swap values of two variables using pointers.
• WAP to largest of the elements of an array using a function and
passing argument using pointer.
• WAP to demonstrate use of a pointer to pointer.
• WAP to demonstrate string handling using pointer.
69. Advantages of using Pointers
• Pointers are variables which store the address of other variables in
C++.
• More than one variable can be modified and returned by function
using pointers.
• Memory can be dynamically allocated and de-allocated using
pointers.
• Pointers help in simplifying the complexity of the program.
• The execution speed of a program improves by using pointers.
75. Identifiers
• Identifiers – variables, functions, arrays, classes created by
programmer.
• Only alphabetic characters, digits and underscore
• Name cannot start with a digit
• Uppercase and lowercase letters are distinct
• Declared keyword cannot be used as variable name
76. Constant
• Refers to fixed values that do not change during execution of a
program
• constant int a = 25;
82. Macros
• A macro is a piece of code in a program that is replaced by the value of the macro. Macro is defined by #define directive.
Whenever a macro name is encountered by the compiler, it replaces the name with the definition of the macro. Macro definitions
need not be terminated by a semi-colon(;)
// C++ program to illustrate macros
#include <iostream>
using namespace std;
// Macro definition
#define LIMIT 5
int main()
{
// Print the value of macro defined
cout << "The value of LIMIT"
<< " is " << LIMIT;
return 0;
}
83. Macros example
// C++ program to illustrate macros
#include <iostream>
using namespace std;
#define AREA(l, b) (l * b)
int main()
{
// Given lengths l1 and l2
int l1 = 10, l2 = 5, area;
// Find the area using macros
area = AREA(l1, l2);
// Print the area
cout << "Area of rectangle“ << " is: "<< area;
return 0;
}
97. • A hospital management want to enhance their software in the
following manner :
• The software should be able to display departments like medicine,
surgery, gynaecology, obstetrics, paediatrics, eye and ENT (any 4)
• The user should be able to view the availability of respective doctors
in the respective department with their charge (fees)
• Once user selects department he/she wants to visit , a tentative bill is
to be generated
• Give the option the user to exit
98. Array
• Declaration :
Datatype arrayName[arraySize]
Few Things to Remember:
• The array indices start with 0. Meaning x[0] is the first element stored at
index 0.
• If the size of an array is n, the last element is stored at index (n-1). In this
example, x[5] is the last element.
• Elements of an array have consecutive addresses. For example, suppose
the starting address of x[0] is 2120.
Then, the address of the next element x[1] will be 2124, the address
of x[2] will be 2128, and so on.
Here, the size of each element is increased by 4. This is because the size
of int is 4 bytes.
100. Another method to initialize array during
declaration:
• / declare and initialize an array
int x[] = {19, 10, 8, 17, 9, 15};
101. To store and print array
#include<iostream.h>
using namespace using std;
main()
{
int i;
int a[6] = {6,23,15,2,18,9};
for(i=0;i<6;i++)
{cout<<a[i]<<endl;}
return 0;
}
102. Examples
For below statements declare array variable.
a. To store integer marks of 10 students.
b. To store yearly average rating of 50 employees.
c. To store 10 characters.
103. Examples
For below arrays find the address of said position.
a. int marks[10]; Find the address of element stored at index 5. Base
address is 1000.
• char c[10]; Find the address of element stored at index 7. Base
address is 1000.
45 70 80 30 67 85 98 34 25 56
A C D R Y N O P E F
105. 2 dimensional array
Write a program to take values for 2-dimensional array and to give
choice to the user for performing below operations:
1. Sum of elements of each row.
2. Sum of diagonal elements.
3. Finding transpose of matrix.
106. Declaring a function
return_type function_name( parameter list )
{ body of the function }
• Return Type − A function may return a value. The return_type is the data type of
the value the function returns. Some functions perform the desired operations
without returning a value. In this case, the return_type is the keyword void.
• Function Name − This is the actual name of the function. The function name and
the parameter list together constitute the function signature.
• Parameters − A parameter is like a placeholder. When a function is invoked, you
pass a value to the parameter. This value is referred to as actual parameter or
argument. The parameter list refers to the type, order, and number of the
parameters of a function. Parameters are optional; that is, a function may contain
no parameters.
• Function Body − The function body contains a collection of statements that
define what the function does.
107. Example
• // function returning the max between two numbers
int max(int num1, int num2) { // local variable declaration
int result;
if (num1 > num2)
result = num1;
else result = num2;
return result; }
108. In main
// function declaration
int max(int num1, int num2);
int main ()
{
// local variable declaration:
int a = 100; int b = 200; int ret;
// calling a function to get max value.
ret = max(a, b);
cout << "Max value is : " << ret << endl;
return 0;
}