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

Программирование на языке C в Microsoft Visual Studio 2010

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

Определите, что делает приведенная программа?
void printBits(unsigned int var);int main (void) {	unsigned int number, mask;	printf("The program on demonstration digit-by-digit operation And ( & )\n");	printf("Enter a whole number of unsigned: ");	scanf_s("%u", &number);	printf("Enter the number of unsigned-mask: ");	scanf_s("%u", &mask);	printf("Binary representation of the starting number(%u) and\n", number);	printf("Binary representation of the number-masks (%u):\n", mask);	printBits(number);	printBits(mask);	printBits(number & mask); 	return 0; }void printBits(unsigned int var) {	unsigned int b;	unsigned int mask = 1 << 15; 	printf("\n%10u = ", var);	for (b = 1; b <= 16; ++b) 	{		printf("%c", var & mask ? '1' : '0');		var <<= 1; 		if (b % 8 == 0)			putchar(' ');	}} 	

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

Варианты ответа
выполняет поразрядную операцию ИЛИ над двумя целыми числами, представленными в двоичной системе счисления для 16-разрядного компьютера
выполняет поразрядную операцию И над двумя целыми числами, представленными в двоичной системе счисления для 32-разрядного компьютера
выполняет поразрядную операцию ИЛИ над двумя целыми числами, представленными в двоичной системе счисления для 32-разрядного компьютера
выполняет поразрядную операцию И над двумя целыми числами, представленными в двоичной системе счисления для 16-разрядного компьютера(Верный ответ)
Похожие вопросы
Определите, что делает приведенная программа?
void printBits(unsigned int var);int main (void) {	unsigned int number1, number2;	printf("\n The program on demonstration digit-by-digit operator OR ( | ):\n");	printf("\n\t Enter the unsigned number of N1: ");	scanf_s("%u", &number1);	printf("\t Enter the unsigned number of N2: ");	scanf_s("%u", &number2);	printf("\n\t Binary representation of the number of N1 (%u) and\n", number1);	printf("\t Binary representation of the number of N2 (%u):\n", number2);	printBits(number1);	printBits(number2);	printBits(number1 | number2); 	printf("\n\n Press any key: ");	_getch();	return 0;}void printBits(unsigned int var) {	unsigned int b;	unsigned int num = 1 << 31; 	printf("\n\t %10u = ", var);	for (b = 1; b <= 32; ++b) {		printf("%c", var & num ? '1' : '0');		var <<= 1; 		if (b % 8 == 0)			putchar(' ');	} } 
Какие утверждения являются верными для приведенной программы?
void fillOnly(int);void free_n(int);void fill_n(int);int main (void) {	int n = 1; 	int in = 1; 	printf("\n Enter a length of string (naturel number): ");	in = scanf_s("%i", &n);	if (in != 1 || n < 1 || n > 15)     {		printf("\n Error input. Press any key to exit: ");		_getch();		exit(0);	}	puts("\n\tResult:");	fill_n(n);	printf("\n\n Press any key to exit: ");	_getch();	return 0;}void fillOnly(int n) {	if (n == 1)		printf("\t%+3d\n", 1);	else {		fillOnly(n-1);		printf("\t%+3d\n", n);		free_n(n-1);	}}void free_n(int n) {	if (n == 1)		printf("\t%+3d\n", -1);	else {		fillOnly(n-1);		printf("\t%+3d\n", -n);		free_n(n-1);	}}void fill_n(int n) {	if (n == 1)		printf("\t%+3d\n", 1);	else {		if (n == 2)			printf("\t%+3d\n\t%+3d\n", 1, 2);		else {			fillOnly(n-1);			printf("\t%+3d\n", n);			fill_n(n-2);		}	}}
Определите, содержит ли приведенная программа ошибки? Если содержит, укажите, какие именно?
#define MAX 20double sum(double, double);int main (void) {	struct test {		char A[MAX+1]; 		double ax; 		char B[MAX+1]; 		double by;	};	struct test AB;		printf("\nEnter 1st name: ");	gets_s(AB.A, MAX);	printf("\nEnter the first real number: ");	scanf_s("%lf", &AB.ax);	_flushall();	printf("\nEnter 2nd name: ");	gets_s(AB.B, MAX);	printf("\nEnter the second real number: ");	scanf_s("%lf", &AB.by);	printf("\n\nThe sum of two numbers %1.2f and %1.2f, %s and %s: %1.2f\n",			AB.ax, AB.by, AB.A, AB.B, sum(ax, by)); 	return 0; }double sum(double x, double y) {	return (x + y);}
Определите, содержит ли приведенная программа ошибки? Если содержит, укажите, какие именно?
int main(void){	struct test {		unsigned int  : 3;		unsigned int f1 : 1;		unsigned int f2 : 1;		unsigned int f3 : 1;		unsigned int type : 8;		unsigned int index : 18;	};		int b;	struct test t, *pt;	pt = &t;	pt->f1 = 11;	t.type = 3439;	b = t.f1 + t.type;	printf("b = %d\n", b);	return 0;}
Какая ошибка содержится в приведенной программе?
int main (void){	typedef struct {    		char nazn[40];  		int numb; 		char time[10];	} train;	train tr[3];		int i = 0, sum = 0, ch=0;	char str[10], search[10];	while(ch!=121) {		printf("\nEnter information about train (Q - quit): \n");		printf("Enter destination of the train: ");		gets(tr[i].nazn);		printf("Enter number of the train: ");		gets(str);		tr[i].numb = atoi(str);		printf("Enter time of scheduled departure: ");		gets(tr[i].time);		++i;		printf("Quit? (y/n): ");		ch = _getche();	};		printf("\n\nEnter train destination: ");	gets(search);	for (i=0; i<3; i++) {		if (strcmp(tr[i].nazn,search)==0) {			printf("\n\tTrain number: %d", tr[i].numb);			printf("\n\tTime: %s", tr[i].time);		}	}	if (i>=3)		printf("There is no train to this destination");    return 0; }
Какие утверждения являются верными для приведенной программы?
#define MAX 20double sum(double, double);int main (void) {	struct test {		char A[MAX+1]; 		double ax; 		char B[MAX+1]; 		double by;	};	struct test AB;		printf("\nEnter 1st name: ");	gets_s(AB.A, MAX);	printf("\nEnter the first real number: ");	scanf_s("%lf", &AB.ax);	_flushall();	printf("\nEnter 2nd name: ");	gets_s(AB.B, MAX);	printf("\nEnter the second real number: ");	scanf_s("%lf", &AB.by);	printf("\n\nThe sum of two numbers %1.2f and %1.2f, %s and %s: %1.2f\n",			AB.ax, AB.by, AB.A, AB.B, sum(AB.ax, AB.by)); 	return 0; }double sum(double x, double y) {	return (x + y);}
Какие утверждения являются неверными для приведенной программы?
#define MAX 20double sum(double, double);int main (void) {	struct test {		char A[MAX+1]; 		double ax; 		char B[MAX+1]; 		double by;	};	struct test AB;		printf("\nEnter 1st name: ");	gets_s(AB.A, MAX);	printf("\nEnter the first real number: ");	scanf_s("%lf", &AB.ax);	_flushall();	printf("\nEnter 2nd name: ");	gets_s(AB.B, MAX);	printf("\nEnter the second real number: ");	scanf_s("%lf", &AB.by);	printf("\n\nThe sum of two numbers %1.2f and %1.2f, %s and %s: %1.2f\n",			AB.ax, AB.by, AB.A, AB.B, sum(AB.ax, AB.by)); 	return 0; }double sum(double x, double y) {	return (x + y);}
Определите, содержит ли приведенная программа ошибки? Если содержит, укажите, какие именно?
int main(void){	struct test {		unsigned int  : 3;		unsigned int f1 : 1;		unsigned int f2 : 1;		unsigned int f3 : 1;		unsigned int type : 8;		unsigned int index : 18;	};		int a : 4, b;	struct test t;	t.type = 3439;	b = a + t.type;	//printf("t.type = %d\n", t.type);	return 0;}		
Какая ошибка содержится в приведенной программе?
int main (void){	typedef struct {    		char nazn[40];  		int numb; 		char time[10];	} train, train_info;	train_info ti[3];	train tr[3];		int i = 0, sum = 0, ch=0;	char str[10], search[10];	while(ch!=121) {		printf("\nEnter information about train (Q - quit): \n");		printf("Enter destination of the train: ");		gets(tr[i].nazn);		printf("Enter number of the train: ");		gets(str);		tr[i].numb = atoi(str);		printf("Enter time of scheduled departure: ");		gets(tr[i].time);		++i;		printf("Quit? (y/n): ");		ch = _getche();	};		printf("\n\nEnter train destination: ");	gets(search);	for (i=0; i<3; i++) {		if (strcmp(tr[i].nazn,search)==0) {			printf("\n\tTrain number: %d", tr[i].numb);			printf("\n\tTime: %s", tr[i].time);		}	}	if (i>=3)		printf("There is no train to this destination");    return 0; }
Какая ошибка содержится в приведенной программе?
int main (void){	struct train_info {    		char nazn[40];  		int numb; 		char time[10];	};	typedef struct train_info train;	train tr[3];		int i = 0, sum = 0, ch=0;	char str[10], search[10];	while(ch!=121) {		printf("\nEnter information about train (Q - quit): \n");		printf("Enter destination of the train: ");		gets(tr[i].nazn);		printf("Enter number of the train: ");		gets(str);		tr[i].numb = atoi(str);		printf("Enter time of scheduled departure: ");		gets(tr[i].time);		++i;		printf("Quit? (y/n): ");		ch = _getche();	};		printf("\n\nEnter train destination: ");	gets(search);	for (i=0; i<3; i++) {		if (strcmp(tr[i].nazn,search)==0) {			printf("\n\tTrain number: %d", tr[i].numb);			printf("\n\tTime: %s", tr[i].time);		}	}	if (i>=3)		printf("There is no train to this destination");    return 0; }