C++
What will ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
What will be the value of a
c
variable after the following code's execution:
int a=4; int b=3; double c=a/b;
1
1.333333
2
Compilation error will occur
Explanation
Since a and b are of
int
type, then a/b will perform an integer division, therefore a/b = 1.
data-type-conversion
implicit-conversion
operators
integer division
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Чему будет равно a после выполнения следующего кода? int а = 7; a /= 2;
Чему будет равно значение выражения 3/5*5 в C++?
В случае следующих приведений типов, какой вывод будет у этой программы? #include <iostream> int main() { float a = 256.5; unsigned char b = static_cast<unsigned char>(a); a += b + 1.f; std::cout << static_cast<int>(a); }
Куда нужно добавить функцию конвертирования "operator int() const", что бы приведенный ниже код скомпилировался? struct B { B() { } virtual const B * f() const { return this; } virtual ~B() { } }; struct D1 : public B { D1() : B() { } const D1 * f() const { return this; } ~D1() { } }; int main() { const B * const b = new D1; const int i = * b->f(); return 0; }
Что будет выведено на экран в результате выполнения следующего кода? #include <iostream> class A { public: A() { } operator int() { return 10; }; operator float() const { return 2.0; }; }; class B { public: B() { } operator int() const { return 5; }; operator float() { return 1.0; }; }; int main() { A a; B b; std::cout << a + b << std::endl; return 0; }
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C++ quizzes
int main() { const int* i = int(); // 1 int const* j = int(); //2 int* const k = int(); //3 int* l(); //4 ++i; //5 ++j; //6 ++k; //7 ++*k; //8 ++l; //9 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции? После стандарта C++14.
Какой результат работы программы? #include <iostream> using namespace std; void f(double) { cout<<"f1"<<endl; } void f(const int ) { cout<<"f2"<<endl; } void f( int & ) { cout<<"f3"<<endl; } void main(void) { int n = 1; double b = 2; f(n); f(b); }
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment