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

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

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

В приведенном фрагменте кода используется константный указатель:
	int lec = 7, qst = 11;	int *const plec = &lec;	int *pqst;	pqst = &qst;	(*plec)++;	printf("Number of the next lection is %d\n", lec );	
Какая ошибка содержится в данном коде?

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

Варианты ответа
константный указатель plec должен адресовать константу, а переменная lec не является константой
константный указатель plec не может быть изменен
приведенный фрагмент не содержит ошибок(Верный ответ)
Похожие вопросы
Какая ошибка содержится в приведеном фрагменте кода?
int min(int, int);int t;int main(void){	register int x=-5, y=5, m;	int *p;	p = &x;	m = min(x,y);	printf("min = %d\n", m);		return 0;}int min(register int a, register int b){	int m = (a<b) ? a : b;	return m;}
Какая ошибка допущена в приведенном фрагменте кода?
double max(double a, b){	if (a>b) 		return a;	return b;}int main(void){	double x=-5.00, y=5.12;	printf("max = %.2f\n", max(x,y));		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; }
Какая ошибка содержится в приведенной программе?
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; }
Определите, что делает приведенная программа?
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(' ');	}} 	
Какая ошибка допущена в приведенной программе?
int main (void) {	enum month {january = 1, february, march, april, may, 				june,july, august, september, october, november, 				december } aMonth;	int days;	printf("\n Enter the number of the month (1 - 12): ");	scanf_s("%d", &aMonth);	switch (aMonth) {		case january:		case march:		case may:		case july:		case august:		case october:		case december:			days = 31;			break;			case april:		case june:		case september:		case november:			days = 30;			break;		case february:			days = 28;			break;		default:			printf("\n\t Wrong number of the month\n");			days = 0;			break; 	}	if (days)	printf("\n The number of days of the month: %d\n", days);	if (aMonth == 2)	printf("\n ... or 29 if it is a leap year\n");	return 0; }
Задан фрагмент кода:
			int n, m;	char *ptr; 	printf(&\nEnter a dimention of character array: &);	scanf_s(&%d&, &n);	_flushall();	ptr = (char *)malloc((n+1)*sizeof(char));	if (!ptr) {	printf(&\nERROR! Out of memmory (error in malloc() function). Press any key...&);	_getch(); 	exit(1); 	}	printf(&Enter a character array (not more than %d characters): &, n);	gets_s(ptr, n+1);	m = strlen(ptr);	printf(&\nStart line: %s&, ptr);	ptr = (char *)realloc(ptr, (m+2)*sizeof(char));	if (!ptr) {		printf(&\nERROR! Out of memmory (error in realloc() function). Press any key...&);		_getch();		exit(1);	}	strcat_s(ptr, m+2,  &!&);	printf(&\nStart line and character \&%c\&: %s&, '!', ptr);		free (ptr);
В запросе размерности массива пользователь задал 80. В запросе ввода строки пользователь ввел строку "Lection 9". Для чего в данном случае будет использована функция realloc()?
Какая ошибка допущена в приведенной программе?
int main (void) {	enum month {january = 1, february, march, april, may, 				june,july, august, september, october, november, 				december } aMonth;	int days;	printf("\n Enter the number of the month (1 - 12): ");	scanf_s("%d", &aMonth);	switch (aMonth) {		case january:		case march:		case may:		case july:		case august:		case october:		case december:			days = 31;			break;			case april:		case june:		case september:		case november:			days = 30;			break;		case february:			days = 28;			break;		default:			printf("\n\t Wrong number of the month\n");			days = 0;			break; 	}	if (days)	printf("\n The number of days of the month: %d\n", days);	if (aMonth == "february")	printf("\n ... or 29 if it is a leap year\n");	return 0; }
Приведенный фрагмент кода должен запрашивать пароль не более трех раз:
	char s[5], psw[] = "password";	int i, k= 0;	for (i=0; !k && i<3; i++) {		printf("Введите пароль: \n"),		gets(s);		if (strcmp(s, psw)) k = 1;	}		if (k) printf("Добро пожаловать! TRUE");	else printf("Ошибка: Неверный пароль! FALSE");
Проверьте правильность этого кода для выполнения поставленной задачи и определите, сколько раз будет выполнен цикл for, если пользователь не знает верного пароля?