please sir i want to comments of every code what i do in eachline . in this w...hwbloom27
please sir i want to comments of every code what i do in eachline .
in this way i good understand this programme.
thanks sri..........
class String
{
public:
string str;
String(string s)
{
str=s;
}
void print(){
cout<<str;
}
String operator+(String obj)
{
string s1=str + obj.str;
return String(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<"\nEnter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
please sir i want to comments of every code what i do in eachline .
in this way i good understand this programme.
thanks sri..........
class String
{
public:
string str;
String(string s)
{
str=s;
}
void print(){
cout<<str;
}
String operator+(String obj)
{
string s1=str + obj.str;
return String(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<"\nEnter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
please sir i want to comments of every code what i do in eachline . in this w...hwbloom27
please sir i want to comments of every code what i do in eachline .
in this way i good understand this programme.
thanks sri..........
class String
{
public:
string str;
String(string s)
{
str=s;
}
void print(){
cout<<str;
}
String operator+(String obj)
{
string s1=str + obj.str;
return String(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<"\nEnter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
please sir i want to comments of every code what i do in eachline .
in this way i good understand this programme.
thanks sri..........
class String
{
public:
string str;
String(string s)
{
str=s;
}
void print(){
cout<<str;
}
String operator+(String obj)
{
string s1=str + obj.str;
return String(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<"\nEnter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
Presentation done at the historic 20 yeras of C++ conference in Las Vegas 2005. This is also the first time I ever spoke on the topic of combing generative programming and C++ template metaprogramming
A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always need to include the header that // defines cin and cout; the header is called iostream.h #include <iostream.h>
int main() {
//variable declaration //read values input from user //computation and print output to user return 0; }
After you write a C++ program you compile it; that is, you run a program called compiler that checks whether the program follows the C++ syntax – if it finds errors, it lists them – If there are no errors, it translates the C++ program into a program in machine language which you can execute.
Modify this code to use multiple threads with the same data1.Modif.pdfmallik3000
Modify this code to use multiple threads with the same data
1.Modify the main function to implement a loop that reads 10 integers from the console (user
input) and stores these numbers in a one-dimensional (1D) array (this code will go right after the
comment that says “Add code to perform any needed initialization or to process user input”).
You should use a global array for this.
2.Implement a separatepthread function function for each one of the following operations:
a.Count and print out how many of the entered numbers are negative. This function must be
named countNegatives
b.Calculate and print the average value of all the numbers entered. This function must be named
average
c.Print the numbers in reverse order from the order in which they were entered. This function
must be named reverse
3.Modify the main function to create one pthread for each one of the functions that you
implemented in (3) above (this code will go between the comment that says “TODO: Modify
according to assignment requirements” and the “if (rc)” check).
Compile your program and run it several times. If the output of your program is garbled, you
may need to add a small delay in between creating the next thread.
#include
#include
using namespace std;
void *routineName(void *arg)
{
// TODO: Add code that implements
// the thread\'s functionality
cout << \"Thread is running...\" << endl;
return 0;
}
int main()
{
pthread_t id;
int rc;
int ints;
for(int x; x<10; x++)
{
cout << \"Enter Integer: \" <>
}
rc = pthread_create(&id, NULL, routineName, NULL);
if (rc){
cout << \"ERROR; return code from pthread_create() is \" << rc << endl;
return -1;
}
pthread_exit(0);
}
Solution
#include
#include
#include
using namespace std;
int ints[10];
//Method to count negatives in the input array
void *countNegatives(void*){
int count = 0;
for(int i=0;i<10;i++){
if(ints[i]<0){
count++;
}
}
cout<<\"Number of negatives: \"<=0;i--){
cout<> ints[x];
}
//Creating pthread to countNegatives
rc = pthread_create(&t1, NULL, countNegatives, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
//Creating pthread to compute average
rc = pthread_create(&t2, NULL, average, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
//Creating pthread to print in reverse
rc = pthread_create(&t3, NULL, reverse, NULL);
if(rc){
cout << \"Error:unable to create thread,\" << rc << endl;
}
//Adding delay
sleep(1);
void* status;
//waiting for t1 to join
rc = pthread_join(t1,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
//waiting for t2 to join
rc = pthread_join(t2,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
//waiting for t3 to join
rc = pthread_join(t3,&status);
if(rc){
cout << \"Error:unable to join,\" << rc << endl;
}
pthread_exit(0);
}.
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.
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...bhargavi804095
C++ is the top choice of many programmers for creating powerful and scalable applications. From operating systems to video games, C++ is the proven language for delivering high-performance solutions across a range of industries.
One of the standout features of C++ is its built-in support of streams. C++ makes it easy to channel data in and out of your programs like a pro. Whether you’re pushing data out to cout or pulling it in from cin, C++ streams are the key to keeping your code in the zone.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
1. Professional slides for your work and your learning
require a guide
require an update
Active tools in your new presentation:
- operations buttons;
- search commands;
- bracket avaible;
- active links to web.
Press F5 to continue.
version 1.2
>>
3. Practical basics on writing C++
I/O and math operation symbols
libraries to include
heading and functions
1
#include <iostream> //proprocessor direcrive
using namespace std;
code for output
cout << "Hello word!n; //this istruction can be write as
//cout << "Hello word!" << endl;
4. Practical basics on writing C++
I/O and math operation symbols
libraries to include
heading and functions
2
#include <iostream> //proprocessor direcrive
using namespace std;
code for input
int number; //name of variable
cin >> number; //reading by system of variable
5. Practical basics on writing C++
I/O and math operation symbols
sum of two operators
+
- subtraction of two operators
division of two operators
/
* product of two operators
calculation of the change in a division between two operators
%
6. Practical basics on writing C++
I/O and math operation symbols
retention of a number in an element
=
== comparision of two elements
increment of 1
++
-- decrease of 1
7. Practical basics on writing C++
I/O and math operation symbols
member b of object a
a.b
*x pointed to by x
adress of x
&x
x->y member y of object pointed to by x
object pointed to by x
x[n]
8. Practical basics on writing C++
Mix input data with output messages
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter a number.n”;
int number;
cin >> number;
cout << “You have endered the number “ << number << endl; //”number”;
return 0; //this istruction return the command to OS and exits from the program
}
result from terminal
Enter a number.
4
You have entered the number 4.
9. Practical basics on writing C++
Condition if…else
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter a number.n”;
int number;
cin >> number;
if (number < 10) { //condition
cout << “The number entered is less than 10.n”; reutrn 0; }
else
cout << “The number entered is higher than 10.n”; return 0;
}
result from terminal
Enter a number.
7
The number entered is less than 10.
Enter a number.
25
The number entered is higher than 10.
This function can be used to
manage errors by user.
10. Practical basics on writing C++
Condition switch
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter 1 to print a message, press 2 to exitn”;
int number_selection;
cin >> number_selection;
switch (number_selection) {
case 1:
cout << “Hi!n”;
return main ();
case 2:
return 0;
default:
cout << “Error! Please, press 1 or 2 keypass.n”;
return main ();
}
}
This function can be used to
project a menu, for example.
1
11. Practical basics on writing C++
Condition switch
result from terminal
Enter 1 to print a message, press 2 to exit.
1
Hi!
Enter 1 to print a message, press 2 to exit.
Enter 1 to print a message, press 2 to exit.
2
This function can be used to
project a menu, for example.
Enter 1 to print a message, press 2 to exit.
3
Error! Please, press 1 or 2 keypass.
Enter 1 to print a message, press 2 to exit.
2
12. Practical basics on writing C++
Cycles: for
code from text editor
#include <iostream>
using namespace std;
int main () {
for (int a = 10; a < 20; a = a+1)
{
cout << “Value: " << a << “.n”;
}
return 0;
}
result from terminal
Value: 10.
Value: 11.
Value: 12.
Value: 13.
Value: 14.
Value: 15.
Value: 16.
Value: 17.
Value: 18.
Value: 19.
Be careful to loops!
13. Practical basics on writing C++
Cycles: while
code from text editor
#include <iostream>
using namespace std;
int main () {
int n = 10; //initialisation
while (n>0) { cout << n << ", ";
--n;
}
cout << "liftoff!n";
}
result from terminal
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, liftoff!
Be careful to loops!
14. Practical basics on writing C++
Cycles: do…while
code from text editor
//example of an echo machine
#include <iostream>
#include <string>
using namespace std;
int main () {
string str;
do {
cout << "Enter text. ";
getline (cin,str);
cout << "You entered the following sentence.n " << str << 'n';
}
while (str != "goodbye");
}
result from terminal
Enter text.
Hello!
You entered the following sentences.
Hello!
Be careful to loops!
do…while executes at least once
the operation, while while and
for could not execute that.
15. Practical basics on writing C++
Arrays and vectors: creations and operations
code from text editor
//declaration of array
int name_of_array[10]; //the array’s size is 10
for(int i=0; i < 14; i++) //initialisarion of array
{
cout << name_of_array[10] << endl; //array’s printing
}
1
16. Practical basics on writing C++
Arrays and vectors: creations and operations
another example
#include <iostream>
using namespace std;
int foo[] = {16, 2, 77, 40, 12071};
int n, result=0;
int main () {
for ( n=0; n<5; ++n) {
result += foo[n];
}
cout << result; return 0;
}
result from terminal
12206
2
17. Practical basics on writing C++
Classes
public class
#include <iostream>
using namespace std;
class rectangle {
int width, height;
public:
rectangle ();
rectangle (int,int);
int area (void) {
return (width * height);
}
};
rectangle::rectangle ()
{width = 5; height = 5;
}
rectangle::rectangle (int a, int b)
{width = a;
height = b;
}
int main () {r
rectangle rect(3,4);
rectangle rectb;
cout << “rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
By default, in C++ the programmer
insert private class type.
1
18. Practical basics on writing C++
Classes
output from bash
rect area: 12
rectb area: 25
2
19. Practical basics on writing C++
Compiling operation
command from bash
g++ <name_of_source_code>.cpp –o <name_of_executable>
20. Practical basics on writing C++
Run command
command from bash
./<name_of_executable>
21. Index
I/O and math operations symbols
Mix input data with output messages
Condition if…else
Compiling operation
Classes
Cycles: for
Cycles: while
Cycles: do…while
Arrays and vectors: creations and operations
24. Get help for free!
marco.izzottialessandro@gmail.com
Priority avaible to anyone.
Marco A. Izzotti
Only for friends.
348 0530717
Avaible only for italians during days.