#include<iostream> int main() { std::cout << "sin(1) = " << std::sin(1.0) << std::endl; std::cout << "cos(1) = " << std::cos(1.0) << std::endl; std::cout << "tan(1) = " << std::tan(1.0) << std::endl; std::cout << "asin(1) = " << std::asin(1.0) << std::endl; std::cout << "acos(1) = " << std::acos(1.0) << std::endl; std::cout << "atan(1) = " << std::atan(1.0) << std::endl; } Output: sin(1) = 0.841471 cos(1) = 0.540302 tan(1) = 1.55741 asin(1) = 1.5708 acos(1) = 0 atan(1) = 0.785398
Assuming the quiz is a simple question/answer style quiz, use a map to associate question strings with answer strings. In order to prevent people from simply examining the program resources to get the answers, you should also consider encrypting the map. For multiple choice quizzes, use a structure containing the question string, a vector of strings for the possible answers and an unsigned integer to identify the correct answer (as an index into the vector).
#include <iostream> int main (void) { std::cout << "\nBitwise AND (&):\n"; for (int a=0; a<=1; ++a) for (int b=0; b<=1; ++b) std::cout << a << " & " << b << " is " << a & b << std::endl; std::cout << "\nLogical AND (&&):\n"; for (int a=0; a<=1; ++a) for (int b=0; b<=1; ++b) std::cout << a << " && " << b << " is " << a && b << std::endl; return 0; }
#include<iostream> #include<sstream> unsigned input_num (std::string prompt, unsigned min, unsigned max) { unsigned num = 0; while (1) { std::cout << prompt << " (range " << min << " - " << max << "): "; std::string input = ""; std::getline (std::cin, input); std::stringstream ss (input); if (ss >> num) { if (num >= min && num <= max) break; else if (num<min) std::cout << "Index must be greater than or equal to " << min << std::endl; else std::cout << "Index must be less than or equal to " << max << std::endl; } else std::cout << "Invalid input." << std::endl; } return (num); } void print_substring (std::string input, unsigned left, unsigned right) { std::cout << input.substr (left, right - left + 1) << std::endl; } int main() { std::cout << "Input string:\t"; std::string input = ""; std::getline (std::cin, input); unsigned left = input_num ("Enter the start index of the substring", 0, input.size()-1); unsigned right = input_num ("Enter the end index of the substring", left+1, input.size()-1); print_substring (input, left, right); }
#include<iostream> #include<fstream> #include<vector> #include<string> std::string get_input_file() { while (true) { std::cout << "Enter the input file name: "; std::string filename; std::getline (std::cin, filename); std::ifstream file (filename); if (file.is_open()) { file.close(); return filename; } std::cerr << "The file could not be opened.\n" << std::endl; } } std::string get_search_word() { while (true) { std::cout << "Enter the word to search for: "; std::string search; std::cin >> search; if (search.size()) return search; std::cerr << "The search word cannot be an empty string.\n" << std::endl; } } std::vector<size_t> get_offsets(const std::string& filename, const std::string& search) { std::vector<size_t> offsets; std::ifstream file (filename); if (!file.is_open()) throw std::exception("The file could not be opened."); size_t offset = 0; while (!file.eof()) { size_t pos = 0; char c; while (!file.read(&c, 1).eof() && c!=search[pos]) ++offset; while (pos!=search.size()-1 && !file.read(&c, 1).eof() && c==search[++pos]); if (pos==search.size()-1 && c==search[pos]) offsets.push_back (offset); offset += pos; pos = 0; } file.close(); return offsets; } int main() { std::cout << "Word Search\n" << std::endl; std::string filename = get_input_file(); std::string search = get_search_word(); std::vector<size_t> offsets = get_offsets (filename, search); std::cout << "The word was found " << offsets.size() << " time" << (offsets.size()==1?"":"s") << ".\n" << std::endl; if (offsets.size()) { std::cout << "Offsets:\n"; for (auto off : offsets) std::cout << off << std::endl; } }
Its there in your house
#include<iostream> int main() { std::cout << "sin(1) = " << std::sin(1.0) << std::endl; std::cout << "cos(1) = " << std::cos(1.0) << std::endl; std::cout << "tan(1) = " << std::tan(1.0) << std::endl; std::cout << "asin(1) = " << std::asin(1.0) << std::endl; std::cout << "acos(1) = " << std::acos(1.0) << std::endl; std::cout << "atan(1) = " << std::atan(1.0) << std::endl; } Output: sin(1) = 0.841471 cos(1) = 0.540302 tan(1) = 1.55741 asin(1) = 1.5708 acos(1) = 0 atan(1) = 0.785398
Assuming the quiz is a simple question/answer style quiz, use a map to associate question strings with answer strings. In order to prevent people from simply examining the program resources to get the answers, you should also consider encrypting the map. For multiple choice quizzes, use a structure containing the question string, a vector of strings for the possible answers and an unsigned integer to identify the correct answer (as an index into the vector).
surveying i third semester question paper
my english
no where
i want solution for mumbai university paper of engg sem 1
m.com 1 year question paper in madras university for previous 5 years
from your frnds
Settle down with 1 person you know will be faithful and has no STD.
i want the blue print for Hindi 1&2 PAPER TO REVISE FOR MY EXAMS FOR 12TH STD
Respect sir/mam, I need all the question paper of mca course in achariya of manonmaniyam university