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

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

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

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

#include <iostream.h>short x = 11, i = 6;void fun1(){  if (i == (x-4)) throw 2; }void fun2(){ --x; fun1();  x++; }int main(){ try    { fun2(); }       catch (int)          { cout << "Exception "; }  cout << x << " " << i;  }

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

Варианты ответа
10 6
Exception 10 6(Верный ответ)
Exception 9 6
Exception
Похожие вопросы

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

    #include <iostream.h>    short x = 10, i = 5;    fun1()      {  if (i == 5) throw 2; }    fun2()      { --x; fun1();  x++; }    int main()      { try          { fun2(); }        catch (int)          { cout << "Exception "; }        cout << x << " " << i;        }

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

    #include <iostream.h>    short x = 4, i = 0;    int fun1()      {  if (i == 0) throw 2; }    int fun2()      { --x; fun1();  x++; }    int main()      { try          { fun2(); }        catch (int)          { cout << "Exception "; }        cout << x << " " << i;      

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

    #include <iostream.h>    #include <fstream.h>    int main ( )    {    int i = 5, j = 10;  double a = 25;   char s[40];    strcpy(s, "Test");    ofstream outfile("c:\\tst.txt");    if (!outfile)      { cout << "Ошибка создания файла";        return 1;  }    outfile << i << ' ' << j << ' ' << a << ' ' << s << endl;    outfile.close();      }    

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

    #include <iostream.h>    #include <fstream.h>    int main( )    {    int i = 1, j = 11;  double a = 2;   char s[40];    strcpy(s, "file");    ofstream outfile("c:\\tst.txt");    if (!outfile)      { cout << "Ошибка создания файла";        return 1;  }    outfile << i << ' ' << j << ' ' << a << ' ' << s << endl;    outfile.close();      }    

Что выводит данная программа, если она верна?

#include <iostream.h>class Х{public:virtual void fun(int a = 0){cout << a;}};class Y: public X{public:virtual void fun(int a = 1) {cout << a ; }};int main(){X *px = new X;px->fun();X *py = new Y;py->fun();return 0;}	

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

    #include <iostream.h>    #include <fstream.h>    int main(      {    int i = 1, j = 25;  double a = 25e6;   char s[40];    strcpy(s, "Test");    ofstream outfile("c:\\test.txt");    if (!outfile)      { cout << "Ошибка создания файла";        return 1;  }    outfile << i << ' ' << j << ' ' << a << ' ' << s << endl;    outfile.close();      }    

Что будет выведено на экран в результате выполнения приведенной ниже программы:

	#include "iostream.h"#include "conio.h"class NewClass{  int x;  int y;  public:  NewClass(int x0,int y0)  {    x=x0;    y=y0;  }  void DISPLAY(void)  {    cout<<x<<" "<<y;  }  NewClass operator+(NewClass obj)  {    NewClass tmp(0,0);    tmp.x=x+obj.x;    tmp.y=y+obj.y;    return tmp;  }};int main(){  NewClass obj1(1,3),obj2(5,8);  obj1=obj1+obj2;  obj1.DISPLAY();  getch();  return 0;}	

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

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

Верен ли нижеприведенный код? Каков результат его работы?

#include <iostream>#include "conio.h"int main(){   enum {t, x, y, z ,w};  cout<<t+x+y+z+w;  getch();  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;}