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

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

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

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

    #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();      }    

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

Варианты ответа
будет выведено сообщение "Ошибка создания файла"
будет создан текстовый файл "C:\tst.txt" с содержимым "5 10 25 Test"(Верный ответ)
будет создан двоичный файл
будет создан текстовый файл "C:\Tst" с содержимым "5 10 25 Test"
в ходе выполнения возникнет исключение
Похожие вопросы

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

    #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 <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>  #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;  }  

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

  #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;   }  

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

  #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.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>#include <fstream>#include <vector>#include <stack>using namespace std;int main(){    ifstream in ("inpnum");    stack <int, vector<int> > s;    int x;    while (in >> x, !in.eof()) s.push(x);    while (! s.empty())    {        x = s.top(); cout << x << " ";        s.pop();    }}

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

#include <iostream>#include "conio.h"int main(){   enum {t, x, y, z ,w};  cout<<t+x+y+z+w;  getch();  return 0;}

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

#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;  }