answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

How can we write a program which orders the elements of a board given there language of programming c plus plus?

In C++ you can use the standard library sort algorithm to sort any data sequence provided the elements support the appropriate comparison operator (std::less<T> for any given type T is used by default). For example: std::vector<int> v {5, 9, 7, 1, 3}; std::sort (v.begin(), v.end()); // v = {1, 3, 5, 7, 9} std::sort (v.begin(), v.end(), std::greater<int>); // v = {9, 7, 5, 3, 1}


How can write a c plus plus program to sort an integer array and name array using function overloading use dynamic memory allocation for both the array?

#include<iostream> #include<vector> #include<string> #include<algorithm> // forward declarations void sort(std::vector<int>&); void sort(std::vector<std::string>&); int main() { std::vector<int> int_array = { 7, 3, 8, 6, 2, 9, 1, 4, 0, 5}; std::vector<std::string> str_array = { "John", "Bill", "Alan", "Craig"}; sort (int_array); sort (str_array); } void sort(std::vector<int>& arr) { std::sort (arr.begin(), arr.end()); } void sort(std::vector<std::string>& arr) { std::sort (arr.begin(), arr.end()); }


How to print the marks of 10 students in c plus plus?

#include<iostream> #include<iomanip> #include<vector> #include<string> #include<random> #include<time.h> struct student_t { unsigned m_student_id; std::string m_student_name; student_t(const unsigned student_id, const std::string& student_name): m_student_id(student_id), m_student_name(student_name) {} }; struct students_t : std::vector<student_t> { students_t() : std::vector<student_t> () { push_back( student_t( 1, "Albert Black")); push_back( student_t( 2, "Charlie Dawson")); push_back( student_t( 3, "Eric Farrel")); push_back( student_t( 4, "Gary Houston")); push_back( student_t( 5, "Iain Jackson")); push_back( student_t( 6, "Kevin Lawson")); push_back( student_t( 7, "Michael Nicholson")); push_back( student_t( 8, "Oscar Peterson")); push_back( student_t( 9, "Robert Stevenson")); push_back( student_t( 10, "Tony Urquart")); } }; struct subject_t { unsigned m_subject_id; std::string m_subject_name; subject_t(const unsigned subject_id, const std::string& subject_name): m_subject_id(subject_id), m_subject_name(subject_name) {} }; struct subjects_t : std::vector<subject_t> { subjects_t() : std::vector<subject_t> () { push_back( subject_t( 1, "English")); push_back( subject_t( 2, "Mathematics")); push_back( subject_t( 3, "Physics")); push_back( subject_t( 4, "Biology")); push_back( subject_t( 5, "Chemistry")); push_back( subject_t( 6, "History")); push_back( subject_t( 7, "Geography")); } unsigned max_length() { // Returns length of longest name. unsigned max=0; for (std::vector<subject_t>::const_iterator isubject=begin(); isubject!=end(); ++isubject) { const subject_t& subject = *isubject; if (max < subject.m_subject_name.size()) max = subject.m_subject_name.size(); } return max; } }; struct mark_t { student_t& m_student; subject_t& m_subject; unsigned m_mark; mark_t(student_t& student, subject_t& subject, const unsigned mark): m_student(student), m_subject(subject), m_mark(mark) {} mark_t& operator= (const mark_t& rvalue) { this->m_student = rvalue.m_student; this->m_subject = rvalue.m_subject; this->m_mark = rvalue.m_mark; return *this; } }; struct marks_t : std::vector<mark_t> { students_t& m_students; subjects_t& m_subjects; marks_t (students_t& students, subjects_t& subjects) : std::vector<mark_t>(), m_students(students), m_subjects(subjects) { // pseudo-random number generator std::default_random_engine generator; generator.seed ((unsigned) time (NULL)); std::uniform_int_distribution<unsigned> distribution (0, 100); for (std::vector<student_t>::const_iterator istudent=students.begin(); istudent!=students.end(); ++istudent) { student_t& student = const_cast<student_t&> (*istudent); for (std::vector<subject_t>::const_iterator isubject=subjects.begin(); isubject!=subjects.end(); ++isubject) { subject_t& subject = const_cast<subject_t&> (*isubject); push_back( mark_t(student, subject, distribution(generator))); } } } std::ostream& print (std::ostream& os) { unsigned last_student_id = 0; for (std::vector<mark_t>::const_iterator imark=begin(); imark!=end(); ++imark) { const student_t& student = imark->m_student; if (last_student_id != student.m_student_id) { if (last_student_id) os << '\n'; last_student_id = student.m_student_id; os << '#' << student.m_student_id << '\t' << student.m_student_name << ":\n" << std::endl; } const subject_t& subject = imark->m_subject; os << '\t' << std::setw (m_subjects.max_length()) << subject.m_subject_name << '\t' << std::setw(3) << imark->m_mark << std::endl; } os << std::endl; return os; } }; int main() { students_t students; subjects_t subjects; marks_t marks (students, subjects); marks.print (std::cout); }


What is the power 73 as a product of the same factor?

7^3 = 7 x 7 x 7


Write a C plus plus program to convert a given number into years weeks and days?

#include<iostream> void num_to_years_weeks_days( unsigned num, unsigned& years, unsigned& weeks, unsigned& days) { years = num / 365; num -= years * 365; weeks = num / 7; num -= weeks * 7; days = num; } int main() { unsigned years, weeks, days; unsigned num = 1000; num_to_years_weeks_days(num, years, weeks, days); std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl; num = 12345; std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl; }

Related Questions

How much is a wind power generator?

The cost of installing a home wind power generator depends on the kilowatt it produces. A 1 kilowatt wind power generator usually costs $3000-$7000. A 7 kilowatt wind power generator costs $20,000-$40,000. The more kilowatt it produces, the more costly it is.


Can a5500 watt generator run a 1 horse power motor?

Yes, a 5500 watt generator should be able to run a 1 horsepower motor. A typical 1 horsepower motor requires around 750-1000 watts to operate, so the generator's output should be sufficient. Just make sure to check the starting wattage of the motor to ensure the generator can handle any initial surge in power.


Where to check maharashtra scholarship exam results of STD 7 and 4 of year 2011?

maharashtra scholarship result of 7 std 2012_2013


How do you find the frequency of positive integers using C plus plus?

#include<iostream> #include<iomanip> #include<map> #include<random> #include<time.h> std::default_random_engine generator; std::uniform_int_distribution<unsigned> distribution (1, 10); typedef std::map<unsigned, unsigned> freq_map; int main() { std::cout << "Program to generate 1,000,000 random numbers in the range 1 to 10\n"; std::cout << "and to print the frequency table for all numbers generated.\n\n"; generator.seed ((unsigned) time (NULL)); freq_map fmap; freq_map::iterator iter; for (unsigned count=0; count<1000000; ++count) { unsigned number = distribution (generator); iter = fmap.find (number); if (iter == fmap.end()) { fmap.insert (freq_map::value_type (number, 1)); } else { ++(iter->second); } } for (iter = fmap.begin(); iter != fmap.end(); ++iter) { std::cout << "The number" << std::setw(3) << iter->first; std::cout << " occurred" << std::setw(7) << iter->second << " times\n"; } std::cout << std::endl; }


How do you size a generator to operate a pump that draws 7 amps on each leg of a 240 Volt Circuit?

At 240 volts, and 7 amp current, you will have a load of 1680 watts (volts x amps = watts). A 2000 watt generator will sufice, however a 3500 watt generator, if within your budget, will power a few other necessities if required.


How do you write a C plus plus program that accepts an integer and checks whether it is divisible by 7?

#include<iostream> #include<sstream> int input_num (std::string prompt) { int num = 0; while (1) { std::cout<<prompt<<": "; std::string input=""; getline (std::cin, input); std::stringstream ss (input); if (ss>>num) break; std::cout<<"Invalid input.\n"; } return (num); } int main() { while (1) { int num = input_num ("Enter a number (0 to exit)"); if (!num) break; if (num%7) std::cout << "The number is not divisible by 7.\n" << std::endl; else std::cout << "The number is divisible by 7.\n" << std::endl; } }


Program for 7 table in c plus plus?

#include<iostream> int main() { for(int i=0; i<=12; ++i ) std::cout<<"7 x "<<i<<" = "<<7*i<<std::endl; return(0); }


How many KVA Generator requeired for 1 ton window ac?

A 1-ton AC can melt a ton of ice in 24 hours. The power needed is theoretically 3517 Watts so allowing for power factor and efficiency you would need a 7 kVA generator.


What are the benefits of a generac generator over a regular generator?

Explore the Generac 25kW Generator—a reliable backup power solution for homes & businesses. With automatic operation, robust performance, and 24/7 power security, it’s ideal for outages. Learn specs, pricing, and benefits. Get yours today!


Can you Give some example of notice std 7?

NOTICE


How do I write a C plus plus program to arrange 7 numbers in ascending order?

#include<iostream> #include<sstream> #include<vector> #include<algorithm> std::ostream& operator<< (std::ostream& os, std::vector<double> v) { os << "{"; for (auto num : v) os << num << ", "; return os << "\b\b} "; } int main () { std::vector<double> v {}; for (size_t in=0; in<7; ++in) { while (true) { std::cout << "Enter a number: "; std::stringstream ss; std::cin >> ss; double d; if (ss >> d) { v.push_back (v); break; } std::cout << "Try again...\n"; } std::cout << "Before sorting: " << v << std::endl; std::sort (v.begin(), v.end()); std::cout << "After sorting: " << v << std::endl; }


What are the ratings and certificates for Generator Gawl - 1998?

Generator Gawl - 1998 is rated/received certificates of: Spain:7