Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 15.07.2012, 20:31   #1
Fstek
Новичок
Джуниор
 
Регистрация: 15.07.2012
Сообщений: 2
По умолчанию Тест по С и С++

Здравствуйте!Помогите,пожалуйста, решить тест,как минимум частично)
1. What does the volatile keyword mean? Select correct answer:
A. It’s used to declare very often modified variables. Compiler uses this information for optimization purposes.
B. It’s used to declare that an object can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread
C. It’s synonym of auto keyword
D. No such a keyword

2. What does this program print? Assume that sizeof(unsigned int) is 4.

Код:
#include <stdio.h>

unsigned int * Arith(unsigned int _int1, unsigned int _int2 )
{
	unsigned int _res;
	_res = _int1 - _int2;
	return &_res;
}

int main()
{
	printf(  “%x\n”,   *Arith( 0, 1 ) );
	return 0;
}
Select correct answer.
A. -1
B. This program isn’t correct because of return operator in Arith function
C. fffffff
D. This program isn’t correct because of printf invocation in main function


3. Global variable is defined as static. What does this mean?
Код:
#include <stdio.h>
static  int  _int = 0;
int foo()
{
   ….
}
Select correct answer.
A. It’s synonym of const keyword
B. Variable _int cannot be referenced in other translation unit
C. It’s used to declare very seldom modified variable. Compiler uses this information for optimization purposes
D. It’s used to declare that an object can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread

4. Local variable is defined as static. What does this mean?

Код:
int foo()
{
	static  int _int = 0;
	…
}
Select correct answer.
A. It’s used to declare that an object can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread
B. Variable _int saves its value between invocation of foo
C. It’s synonym of const keyword

5. Is this code correct?

Код:
#include <stdio.h>

struct MyStruct
{
	int int1;
	float float1;
};

static struct MyStruct tolick;

struct MyStruct * foo()
{
	int _int = 0;
	scanf("%d", &_int);

	if ( _int == 0 )
	{
		tolick.int1 = 1;
		return &tolick;
	}
	else
	{
		return NULL;
	}
}

int main()
{
	struct MyStruct  *ps = NULL;

	ps = foo();

	if ( ps != NULL && ps->int1 != 0  )
	{
		printf( "Ok\n" );
	}
	else
	{
		printf( "It's not ok\n" );
	}

	return 0;
}
Select correct answer:
A. Operator return &tolick is incorrect in foo function
B. This code is not correct because if ps is NULL machine attempts to read ps->int1
C. This code is correct
D. Variable tolick is read only

6. What will be the output of the program?

Код:
#include <stdio.h>

int main()
{
	 int i=5;
	 int j=5;

	 printf( "%d   ", i++ );
	 printf( "%d\n", ++j );

	 return 0;
}
Select correct answer:
A. 6 5
B. 5 5
C. 5 6
D. 6 6
C++

7. What is correct about virtual function?
Select correct answer:
A. It must be redefined in child class
B. It should not return value
C. It could be overwritten in child class
D. Given a base class pointer to a child class object, virtual function defined in the child class will be called

8. What is correct about a reference in a function argument list?
Select correct answer:
A. Same as pointer
B. Same variable as in caller function
C. Return value of virtual function
D. Global variable

9. What is correct template class declaration?
Select correct answer:
A. class x <class T> { }
B. template <class T> class X { }
C. class x <template class T> { }
D. template <class T> T X ( ) { }

10. What are correct streaming operators for declaration: ofstream myfile ("example.txt")?
Select correct answer:
A. myfile << “some string”;
B. myfile >> int_variable;
C. 10 >> myfile;
D. myfile << myfile;

11. What is the output of the following program? Assume that target machine has 32bit architecture.

Код:
#include <iostream>
class foo
{
	public: 
	void f1 ()
	{
		std::cout << "foo::f1" << std::endl;
	}
	virtual void f2 ()
	{
		std::cout << "foo::f2" << std::endl;
	}
	foo()
	{
		std::cout << "foo::foo" << std::endl;
	}
	virtual ~foo()
	{
		std::cout << "foo::~foo" << std::endl;
	}
};


class bar: virtual public foo
{
	public:
	void f1 ()
	{
		std::cout << "bar::f1" << std::endl;
	}
	virtual void f2 ()
	{
		std::cout << "bar::f2" << std::endl;
	}
	bar()
	{
		std::cout << "bar::bar" << std::endl;
	}
	virtual ~bar()
	{
		std::cout << "bar::~bar" << std::endl;
	}
};
int main()
{
	foo * a_foo = new bar;
	a_foo->f1();
	a_foo->f2();
	delete a_foo;
	return 0;
}
Fstek вне форума Ответить с цитированием
Старый 15.07.2012, 22:14   #2
Fstek
Новичок
Джуниор
 
Регистрация: 15.07.2012
Сообщений: 2
По умолчанию

С частью,касающейся С++ разобрался(точнее помогли на другом форуме),но С по-прежнему нуждается во внимании программеров)
Fstek вне форума Ответить с цитированием
Старый 16.07.2012, 02:06   #3
rlib
Форумчанин
 
Аватар для rlib
 
Регистрация: 22.05.2012
Сообщений: 352
По умолчанию

1. B
2. Проверьте: http://codepad.org/
3. B
4. B
5. C
6. Проверьте: http://codepad.org/
rlib вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Тест Рузька HTML и CSS 3 26.05.2012 21:18
Тест Kinect Общие вопросы .NET 2 08.05.2011 23:02
Тест Bamz Общие вопросы Delphi 4 05.12.2008 00:55
Тест SERG1980 БД в Delphi 1 20.07.2007 12:58
Тест djeyana Общие вопросы по Java, Java SE, Kotlin 0 28.06.2007 00:19