The document discusses functions in C++. It explains that functions can be defined in two ways: with declaration/calling/definition or with just declaration and definition. It provides examples of declaring a function that calculates the average of two numbers, calling that function, and defining the function. It also discusses local and global variables and their scopes. Finally, it lists some common predefined functions in C++ like sqrt, pow, abs, and rand.
A brief look at the new features coming in Javascript ES6:
- Scope and control
- Iterators and Generators
- Collections
- Typed objects
- Direct proxies
- Template strings
- API improvements
- Modularity
Explaining ES6: JavaScript History and What is to ComeCory Forsyth
An overview of some of the history of JavaScript, how it became ECMAScript (and what Ecma is), as well as highlights of the new features and syntax in ES6 aka ES2015.
Originally presented to the New York Public Library on June 4 2015.
A brief look at the new features coming in Javascript ES6:
- Scope and control
- Iterators and Generators
- Collections
- Typed objects
- Direct proxies
- Template strings
- API improvements
- Modularity
Explaining ES6: JavaScript History and What is to ComeCory Forsyth
An overview of some of the history of JavaScript, how it became ECMAScript (and what Ecma is), as well as highlights of the new features and syntax in ES6 aka ES2015.
Originally presented to the New York Public Library on June 4 2015.
02 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 3 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-3
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
A class that automates conversion from a C++ recursive function to an iterative function. It allow the recursive function to preserve its structure by reproducing the "call stack" on an std::stack. The examples use combinatorics to illustrate usage.
03 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 2 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-2
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
Bob Tiernay explores the fascinating world of jq, "the JSON Processor”. Starting with a motivation, he then covers the language, provides helpful tips, showcases a real world example, cautions some things to avoid and finishes with a discussion of the ecosystem.
JSON is a well-known, lightweight format for data exchange around the web. It’s a structured data format used in modern APIs and goes really well with web applications. But how do you work with these JSON files directly and perform operations on it? This is where JQ comes into play.
JQ is a flexible, lightweight, command-line processor that is like ‘sed’ for JSON data. JQ gets along well with UNIX pipes and offers rich functionality to interrogate, manipulate, and work with JSON files.
In this webinar, you will be introduced to JQ and you will learn how to work with basic filters, operators & functions, conditionals & comparisons. You will also learn how to define functions, work with Regex, and use streaming JSON data in JQ.
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
C++ programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
Implementing Software Machines in C and GoEleanor McHugh
The next iteration of the talk I gave at Progscon, this introduces examples of Map implementation (useful for caches etc.) and outlines for addition of processor core code in a later talk.
Our new blog post featuring some common python programming patterns and their C++ equivalents is now up!
Leave us a comment below and let us know what you'd like to see covered in our future posts!
█ Read More
Technical Insights: Introduction to GraphQL|goo.gl/d7PyXH
02 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 3 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-3
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
A class that automates conversion from a C++ recursive function to an iterative function. It allow the recursive function to preserve its structure by reproducing the "call stack" on an std::stack. The examples use combinatorics to illustrate usage.
03 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 2 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-2
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
Bob Tiernay explores the fascinating world of jq, "the JSON Processor”. Starting with a motivation, he then covers the language, provides helpful tips, showcases a real world example, cautions some things to avoid and finishes with a discussion of the ecosystem.
JSON is a well-known, lightweight format for data exchange around the web. It’s a structured data format used in modern APIs and goes really well with web applications. But how do you work with these JSON files directly and perform operations on it? This is where JQ comes into play.
JQ is a flexible, lightweight, command-line processor that is like ‘sed’ for JSON data. JQ gets along well with UNIX pipes and offers rich functionality to interrogate, manipulate, and work with JSON files.
In this webinar, you will be introduced to JQ and you will learn how to work with basic filters, operators & functions, conditionals & comparisons. You will also learn how to define functions, work with Regex, and use streaming JSON data in JQ.
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
C++ programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
Implementing Software Machines in C and GoEleanor McHugh
The next iteration of the talk I gave at Progscon, this introduces examples of Map implementation (useful for caches etc.) and outlines for addition of processor core code in a later talk.
Our new blog post featuring some common python programming patterns and their C++ equivalents is now up!
Leave us a comment below and let us know what you'd like to see covered in our future posts!
█ Read More
Technical Insights: Introduction to GraphQL|goo.gl/d7PyXH
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
It tells about functions in C++,Types,Use,prototype,declaration,Arguments etc
function with
A function with no parameter and no return value
A function with parameter and no return value
A function with parameter and return value
A function without parameter and return value
Call by value and address
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
This reference will take you through simple and practical approach while learning C++ Programming language.
How to add an interactive shell (remote, too) to a C++ application by using my open-source C++14 library:
https://github.com/daniele77/cli
In the slide deck you can learn how to use it, how does it work, and find some thoughts about C++ design and patterns used by the library.
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
The slides from the C++ and OOPS Crash Course conducted for ACM DBIT by Grejo Joby.
Learn the concepts of OOPS and C++ Programming in the shortest time with these notes.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
4. Functions
•Two ways to write functions in your program:
•Declaration / calling / definition
5. Functions
•Two ways to write functions in your program:
•Declaration / calling / definition
Before main
Inside main
After main
6. Functions
•Two ways to write functions in your program:
•Declaration / calling / definition
•Declaration + definition / calling
7. Functions
•Declaration / calling / definition
#include<iostream>
using namespace std ;
Float avg(float x, float y ) ;
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avg : "<<c<<endl;
system("pause");
return 0;
}
float avg(float x, float y )
{
return (x+y)/2;
}
8. #include<iostream>
using namespace std ;
Float avg(float x, float y ) ;
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avg : "<<c<<endl;
system("pause");
return 0;
}
float avg(float x, float y )
{
return (x+y)/2;
}
Functions
•Declaration / calling / definition
Declaration
9. #include<iostream> using namespace std ; Float avg(float x, float y ) ; int main () { float x,y; cout<<" Enter the first number: n"; cin>>x; cout<<" Enter the second number: n"; cin>>y; float c=avg(x,y); cout<<"the avg : "<<c<<endl; system("pause"); return 0; } float avg(float x, float y ) { return (x+y)/2; }
Functions
•Declaration / calling / definition
Declaration
calling
10. #include<iostream>
using namespace std ;
Float avg(float x, float y ) ;
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avg : "<<c<<endl;
system("pause");
return 0;
}
float avg(float x, float y )
{
return (x+y)/2;
}
Functions
•Declaration / calling / definition
Declaration
calling
Definition
11. Functions
•Declaration + definition / calling
#include<iostream> using namespace std ; float avg(float x, float y ) { return (x+y)/2; } int main () { float x,y; cout<<" Enter the first number: n"; cin>>x; cout<<" Enter the second number: n"; cin>>y; float c=avg(x,y); cout<<"the avssg : "<<c<<endl; system("pause"); return 0; }
12. Functions
•Declaration + definition / calling
#include<iostream> using namespace std ; float avg(float x, float y ) { return (x+y)/2; } int main () { float x,y; cout<<" Enter the first number: n"; cin>>x; cout<<" Enter the second number: n"; cin>>y; float c=avg(x,y); cout<<"the avssg : "<<c<<endl; system("pause"); return 0; }
Declaration+ definition
13. Functions
•Declaration + definition / calling
#include<iostream> using namespace std ; float avg(float x, float y ) { return (x+y)/2; } int main () { float x,y; cout<<" Enter the first number: n"; cin>>x; cout<<" Enter the second number: n"; cin>>y; float c=avg(x,y); cout<<"the avssg : "<<c<<endl; system("pause"); return 0; }
Declaration+ definition
calling
14. Functions
#include<iostream> using namespace std ; float avg(float x , float y ) { return (x+y)/2; } int main () { float x,y; cout<<" Enter the first number: n"; cin>>x; cout<<" Enter the second number: n"; cin>>y; float c=avg(x,y); cout<<"the avssg : "<<c<<endl; system("pause"); return 0; }
Returned value
15. Functions
#include<iostream>
using namespace std ;
float avg(float x , float y )
{
return (x+y)/2;
}
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avssg : "<<c<<endl;
system("pause");
return 0;
}
It could be Void , then no return and no “ = ”
16. Functions
#include<iostream>
using namespace std ;
float avg(float x , float y )
{
return (x+y)/2;
}
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avssg : "<<c<<endl;
system("pause");
return 0;
}
Attention !!
“ , ” Not “ ; ”
17. Functions
#include<iostream>
using namespace std ;
float avg(float x , float y )
{
return (x+y)/2;
}
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avssg : "<<c<<endl;
system("pause");
return 0;
}
Variables like in procedures & functions in Pascal !
18. Functions
#include<iostream>
using namespace std ;
float avg(float x , float y )
{
return (x+y)/2;
}
int main ()
{
float x,y;
cout<<" Enter the first number: n";
cin>>x;
cout<<" Enter the second number: n";
cin>>y;
float c=avg(x,y);
cout<<"the avssg : "<<c<<endl;
system("pause");
return 0;
}
Also , it could be null
Float avg()
20. Predefined Functions
•It’s existing in libraries in C++
•You can call it without writing any definition or declaration !!
•You have to put using namespace std with all functions !
21. Predefined Functions
Name
Description
Type of
Arguments
Type of
Value
Example
Value
Library
Header
sqrt
Square root
double
double
sqrt(4.0)
2.0
cmath
pow
Powers
double
double
pow(2.0,3.0)
8.0
cmath
abs
Absolute value for int
int
int
abs(-7)
abs(7)
7
7
cstdlib
labs
Absolute value for long
long
long
labs(-70000) labs(70000)
70000 70000
cstdlib
fabs
Absolute value for double
double
double
fabs(-7.5) fabs(7.5)
7.5
7.5
cmath
ceil
Ceiling (round up)
double
double
ceil(3.2) ceil(3.9)
4.0
4.0
cmath
floor
Floor (round down)
double
double
floor(3.2) floor(3.9)
3.0
3.0
cmath
exit
End program
int
void
exit(1);
None
cstdlib
rand
Random number
None
int
rand( )
Varies
cstdlib
srand
Set seed for rand
unsigned int
void
srand(42);
None
cstdlib
22. Predefined Functions
Name
Description
Type of
Arguments
Type of
Value
Example
Value
Library
Header
sqrt
Square root
double
double
sqrt(4.0)
2.0
cmath
pow
Powers
double
double
pow(2.0,3.0)
8.0
cmath
abs
Absolute value for int
int
int
abs (-7)
abs(7)
7
7
cstdlib
labs
Absolute value for long
long
long
labs(-70000) labs(70000)
70000 70000
cstdlib
fabs
Absolute value for double
double
double
fabs(-7.5) fabs(7.5)
7.5
7.5
cmath
ceil
Ceiling (round up)
double
double
ceil(3.2) ceil(3.9)
4.0
4.0
cmath
floor
Floor (round down)
double
double
floor(3.2) floor(3.9)
3.0
3.0
cmath
exit
End program
int
void
exit(1);
None
cstdlib
rand
Random number
None
int
rand( )
Varies
cstdlib
srand
Set seed for rand
unsigned int
void
srand (42);
None
cstdlib
23. ///Computes the size of a doghouse that can be purchased //given the user’s budget. #include <iostream> #include <cmath> using namespace std; int main( ){ const double COST_PER_SQ_FT = 10.50; //cost per square feet double budget, area, lengthSide; cout << "Enter the amount budgeted for your doghouse $"; cin >> budget; area = budget/COST_PER_SQ_FT; lengthSide = sqrt(area); cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "For a price of $" << budget << endl << "I can build you a luxurious square doghousen" << "that is " << lengthSide << " feet on each side.n"; return 0; }
Predefined Functions
24. #include <iostream>
#include <cstdlib>
using namespace std;
int main( ){
int month, day;
cout << "Welcome to your friendly weather program.n"
<< "Enter today’s date as two integers for the month and the day:n";
cin >> month;
cin >> day;
srand(month*day); //using seed number=month*day
int prediction;
char ans;
cout << "Weather for today:n";
do{
prediction = rand( ) % 3 ;// Scaling
switch (prediction){
case 0:
cout << "The day will be sunny!!n";
break;
case 1:
cout << "The day will be cloudy.n";
break;
case 2:
cout << "The day will be stormy!n";
break;
default:
cout << "Weather program is not functioning properly.n";
}
cout << "Want the weather for the next day?(y/n): ";
cin >> ans;
} while (ans == 'y' || ans == 'Y');
cout << "That's it from your 24-hour weather program.n";
Return 0 ;
}
Code discussion 3
27. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream>
using namespace std ;
int main (){
float x;
cout<<" Enter the number: n";
cin>>x;
{
float x=22;
}
cout<<"the number x : "<<x<<endl;
system("pause"); return 0;
}
Block!
28. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream> using namespace std ; int main (){ float x; cout<<" Enter the number: n"; cin>>x; { float x=22; } cout<<"the number x : "<<x<<endl; system("pause"); return 0; }
29. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream>
using namespace std ;
int main (){
float x;
cout<<" Enter the number: n";
cin>>x;
{
float x=22;
}
cout<<"the number x : "<<x<<endl;
system("pause"); return 0;
}
30. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream> using namespace std ; int main (){ float x; cout<<" Enter the number: n"; cin>>x; { float x=22; } cout<<"the number x : "<<x<<endl; system("pause"); return 0; }
31. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream> using namespace std ; int main (){ float x; cout<<" Enter the number: n"; cin>>x; { float x=22; } cout<<"the number x : "<<x<<endl; system("pause"); return 0; }
32. Local & global Variables
•Local Variables
•It’s scope is the current ‘Block’ and all the ‘nested- blocks’ .
•You can use the same name of variables in different scopes !
#include<iostream> using namespace std ; int main (){ float x; cout<<" Enter the number: n"; cin>>x; { float x=22; } cout<<"the number x : "<<x<<endl; system("pause"); return 0; }
34. Local & global Variables
•Global Variables
•At the first of program ( after “using namespace std” )
•It’s scope , all ‘blocks’
•If you have global variable (name x ) and other local variable ( name x too )
•If you want global x , you will write ::x
48. Overloading
•The same functions names ,but different meanings
•Returned_value Fname ( int v1 , double v1 …. )
•Returned_value Fname ( double v1 , double v1 …. )
•Returned_value Fname ( char v1 , double v1 …. )
Difference here
At parameters !
49. Overloading
•The same functions names ,but different meanings
•Returned_value Fname ( int v1 , double v1 …. )
•Returned_value Fname ( double v1 , double v1 …. )
•Returned_value Fname ( char v1 , double v1 …. )
Difference here At parameters !
In numbers of them , and in their kinds
50. Overloading
•The same functions names ,but different meanings
•Returned_value Fname ( int v1 , double v1 …. )
•Returned_value Fname ( double v1 , double v1 …. )
•Returned_value Fname ( char v1 , double v1 …. )
Difference here At parameters !
In numbers of them , and in their kinds
Not here at returned value !
51. Overloading
•The same functions names ,but different meanings
•Returned_value Fname ( int v1 , double v1 …. )
•Returned_value Fname ( double v1 , double v1 …. )
•Returned_value Fname ( char v1 , double v1 …. )
•You will see it on operators + , - , * ….
57. Homework
•Write a program that calls a function , in function the user input a Float number (ex: 3.6) , then the output is “ (3) and (0.6) “
•Write a program that calls a Recursive function , in function the user input an integer number (ex: 3) , then the output is “ (3! = 6) “