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

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

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

Определите, содержит ли приведенное объявление структур ошибки? Если содержит, то укажите, какие именно?
struct A {int a; double x; };struct B {A a; B b; double x; }; 

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

Варианты ответа
элемент структуры B не может иметь тип другой структуры A
поля разных структур в одной программе не могут иметь одинаковые имена
элементы b структуры B не может иметь тип этой же структуры(Верный ответ)
объявления не содержат ошибок
Похожие вопросы
Определите, содержит ли приведенная программа ошибки? Если содержит, укажите, какие именно?
#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){	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;}		
Содержит ли приведенная программа ошибки? Если содержит, укажите, какие?
struct struct_type {  int a, b;  char ch;} ;struct struct_type2 {  int a, b;  char ch;} ;void f1(struct struct_type2 parm);int main(void){  struct struct_type arg;  arg.a = 1000;  f1(arg);   return 0;}void f1(struct struct_type2 parm){  printf("%d", parm.a);}
Какие утверждения являются верными для приведенной программы?
#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);}
Задан указатель double **m на массив указателей:
			int i;	double **m;	m = (double **)calloc(10,sizeof(double *));	for (i=0; i<10; i++)		m[i] = (double *)calloc(5,sizeof(double));
Как в данном случае освободить выделенную память?
Какую ошибку содержит приведенная программа?
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);}
Какой файл будет создан в результате выполнения приведенной программы?
int main (void){	struct student {    		char *name;  		char *surname; 		int group;         		int ses[5];		double av;		struct student *p;	} st; 	FILE *fp;	int i, sum = 0;	st.name = "Ivan";	st.surname = "Ivanov";	st.group = 1024;	st.ses[0] = 5;	st.ses[1] = 4;	st.ses[2] = 5;	st.ses[3] = 5;	st.ses[4] = 5;	for (i=0; i<5; i++) sum +=st.ses[i];	st.av = sum/5;		if ((fp = fopen("g:\\marks.txt", "w+t")) == 0)		printf("Open file error");	else {		fprintf(fp, "Name: %s %s\n", st.surname, st.name);		fprintf(fp, "Group: %d\n", st.group);		fprintf(fp, "Average mark: %.2f\n\n", st.av);		fclose(fp);	};    return 0; }
В приведенной программе происходит инициализация структуры данных о студенте и последующий вывод этих данных:
struct student {	char fio[30];	int group;	float average;};struct student Init(char*, int, float);void Print(struct student*);int main(void){	struct student s, *st;	int i;	st = Init("Ivanov I.", 3801, 5.00);	Print(st);	return 0;}struct student Init(char* n, int i, float f){	struct student s, *st;	st = &s;	strcpy(st->fio, n);	st->group = i;	st->average = f;	return s;}void Print(struct student *st){	printf("\nName: %s", st->fio);	printf("\nGrouproup: %d", st->group);	printf("\nAverage mark: %.2f\n", st->average);}
Какие утверждения являются верными для приведенной программы?