База ответов ИНТУИТ

Язык программирования C++ для профессионалов

<<- Назад к вопросам

Что будет напечатано в результате работы следующей программы?

  int main()  { int a = 0, x = 2;    for (int i = 0; i < 1; i++)      { a++;        if (i == 1) goto B;        x++;      }    if (a > x) goto C;    /* x = 5; */    C:  a -= x;    B:  a += x;    cout << a << " " << x;    return 0;  }  

(Отметьте один правильный вариант ответа.)

Варианты ответа
1 3(Верный ответ)
ошибка выполнения
1 2
2 3
Похожие вопросы

Что будет напечатано в результате работы следующей программы?

	main()  { int a = 0, x = 2;    for (int i = 0; i < 4; i++)      { a++;        if (i == 1) goto B;        // x++;      }    if (a < x) goto C;    x = 5;    C:  a -= x;    B:  a += x;    cout << a <<  " " << x;  }	

Что будет напечатано в результате работы следующей программы?

  main()  { int a = 0, x = 0;    for (int i = 0; i < 4; i++)      { a++;        if (i == 2) goto B;        x++;      }    if (a > x) goto C;    x = 10;    C:  a -= x;    B:  a += x;    cout << a << " " << x;  }  

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  int f1(int x, int y)    {  return x + y; }  int f2(int x, int y)    {  return x * x + y * y; }  int (*pf1)(int, int);  int (*pf2)(int, int);  main()  { pf1 = &f1;    pf2 = &f2;    int x = 2, y = 3;    cout << (*pf1)(x, y) << ' ' << (*pf2)(x, y) << endl;  }  

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  double s2(double x)    { return x*x; }  double s3(double x)    { return x*s2(x); }  double s4(double x)    { return s2(x)*s2(x); }  int main()  { typedef double (*PTF)(double);     PTF pf[3] = {&s2, &s3, &s4};     double x = 2;     for(int i = 0; i < 3; i++)         cout << (*pf[i])(x) << endl;     return 0;   }  

Чему будет равняться значение переменной x после выполнения следующего кода:

#include "iostream.h"#include "conio.h"int main(){  int x=1;  M2:;  for(int i=1;i<5;i++,x++);  if(x>5)    goto M1;  else    goto M2;  M1: cout<<x;  getch();  return 0;}

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  #include <math>  double s2(double x)    {  return sqrt(x); }  double s3(double x)    {  return sqrt(s2(x)); }  double (*pf1)(double);  double (*pf2)(double);  main()  { pf1 = &s2;    pf2 = &s3;    cout << (*pf1)(25) << ' ' << (*pf2)(16) << endl;  }  

Что будет напечатано в результате работы программы:

  class A   { public: A() { cout << "A "; };            virtual A* new_A() { return new A(); }  };  class B : public A   { public: B(){ cout << "B " ;};            A* new_A() { return new B(); }  };  void fun(A* p1, A* p2)  { A* p3 = p1->new_A();    A* p4 = p2->new_A();  }  void main()  { A* p1 = new A;    B* p2 = new B;    fun(p1,p2);  }    

Какой будет результат выполнения следующей программы?

int main(){  int i = 5;  int* pi = &i;  void * v = pi;  pi = v;  cout << *pi;  return 0;}  

Какой будет результат выполнения следующей программы?

  int SM(const int A[], int N)  { int S = A[0];    for (int i = 1; i < N; i++) S += A[i];    return S;  }    int main()  {   #define Bmax 6    int B[6] = {1, 2, 3, 4, 5, 6};    cout << SM(B + 3, Bmax - 3) << endl;    return 1;  }  

Какой будет результат выполнения следующей программы?

  int SM(const int A[], int N)  { int S = A[0];    for (int i = 1; i < N; i++) S += A[i];    return S;  }    int main()  {   #define Bmax 3    int B[5] = {1, 2, 3};    cout << SM(B, Bmax) << endl;  }