We can also define a user-defines manipulators.
- ATrue
- BFalse
C++ lets programmers write their own manipulators.
MCQs, short and long questions from lecture 38.Lecture 38 ki MCQs, short aur long sawal.
1 MCQ · 2 long questions · 1 MCQ from past papers1 MCQ · 2 long sawal · 1 MCQ past papers se
We can also define a user-defines manipulators.
C++ lets programmers write their own manipulators.
No MCQs match this filter.Is filter mein koi MCQ nahi.
No short questions added yet.Abhi koi short sawal shamil nahi.
Write a small program which defines a user-defined manipulator named Octal. This manipulator should convert and display the decimal number into octal form. In the main function, You have to take a decimal number as an input from the user and then by using the user-defined manipulator display the number in octal form.
#include <iostream> using namespace std; ostream& Octal(ostream &os) { os << oct; // switch the stream to octal return os; } int main() { int num; cout << "Enter a decimal number: "; cin >> num; cout << "Octal form: " << Octal << num << dec << endl; return 0; }
Write a small program which defines a user define manipulator named star, this manipulator should display the output separated by four stars. For example the output of the program should look like this Virtual****University
#include <iostream> using namespace std; ostream & star(ostream &os) { os << "****"; return os; } int main() { cout << "Virtual" << star << "University" << endl; return 0; }