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

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

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

Какие утверждения являются верными для приведенной программы?
#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);}

(Ответ считается верным, если отмечены все правильные варианты ответов.)

Варианты ответа
в функцию sum передаются части структуры(Верный ответ)
для корректного выполнения программы структура test должна быть объявлена глобально
программа не содержит ошибок(Верный ответ)
в функцию sum передается структура
Похожие вопросы
Какие утверждения являются неверными для приведенной программы?
#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(ax, by)); 	return 0; }double sum(double x, double y) {	return (x + y);}
Какая ошибка содержится в приведенной программе?
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; }
Какая ошибка содержится в приведенной программе?
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; }
Что необходимо сделать для того, чтобы исправить содержащуюся в программе ошибку?
void Init(struct student*);void Print(struct student*);int main(void){	struct student {		char fio[30];		int group;		float average;	};	struct student s, *st;	int i;	st = &s;	Init(st);	Print(st);	return 0;}void Init(struct student *st){	printf("\nEnter name: ");	scanf("%s", st->fio);	printf("\nEnter group: ");	scanf("%d", &st->group);	printf("\nEnter average mark: ");	scanf("%f", &st->average);}void Print(struct student *st){	printf("\nName: %s", st.fio);	printf("\nGrouproup: %d", st.group);	printf("\nAverage mark: %.2f", st.average);}
Что необходимо сделать для того, чтобы исправить содержащуюся в программе ошибку?
void Init(struct student*);void Print(struct student*);int main(void){	struct student {		char fio[30];		int group;		float average;	};	struct student s, *st;	int i;	st = &s;	Init(&st);	Print(st);	return 0;}void Init(struct student *st){	printf("\nEnter name: ");	scanf("%s", st.fio);	printf("\nEnter group: ");	scanf("%d", &st.group);	printf("\nEnter average mark: ");	scanf("%f", &st.average);}void Print(struct student *st){	printf("\nName: %s", st->fio);	printf("\nGrouproup: %d", st->group);	printf("\nAverage mark: %.2f", st->average);}
Какую ошибку содержит приведенная программа?
void Init(struct student*);void Print(struct student*);int main(void){	struct student {		char fio[30];		int group;		float average;	};	struct student s, *st;	int i;	st = &s;	Init(st);	Print(st);	return 0;}void Init(struct student *st){	printf("\nEnter name: ");	scanf("%s", st->fio);	printf("\nEnter group: ");	scanf("%d", &st->group);	printf("\nEnter average mark: ");	scanf("%f", &st->average);}void Print(struct student *st){	printf("\nName: %s", st->fio);	printf("\nGrouproup: %d", st->group);	printf("\nAverage mark: %.2f", st->average);}
При каких значениях размерности n символьного массива и строки, на которую указывает указатель ptr, в результате выполнения приведенной программы возникнет ошибка?
		#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <string.h>int main(void) {	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);	strcat_s(ptr, m+2,  "!");	printf("\nStart line and character \"%c\": %s", '!', ptr);		free (ptr);	printf("\n\nPress any key: ");	_getch();	return 0; }
Какая ошибка допущена в приведенном фрагменте кода?
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;}