Can the following C code be compiled successfully?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .f = 3, .k = 1};
printf("%f\n", x.f);
}
C-structures , bitfields,union and File Handling
Quiz
•
Professional Development
•
University
•
Hard
Shaik Imam
Used 3+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Can the following C code be compiled successfully?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .f = 3, .k = 1};
printf("%f\n", x.f);
}
Depends on the standard
No
Depends on the platform
Yes
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following C code?
#include <stdio.h>
struct student
{
int no;
char name[20];
};
void main()
{
student s;
s.no = 8;
printf("%d",s.no);
}
Nothing
8
Compile time error
Junk
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
#include <stdio.h>
union uTemp
{
double a;
int b[10];
char c;
}u;
4
8
40
80
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following C code
#include <stdio.h>
union temp
{
int a;
float b;
char c;
};
int main()
{
union temp s = {1,2.5,’A’};
printf("%c",s.c);
return 0;
}
'1'
Compilation error
'A'
Nothing
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following C code? (Assuming size of char = 1, int = 4, double = 8)
#include <stdio.h>
union utemp
{
int a;
double b;
char c;
}u;
int main()
{
u.c = 'A';
u.a = 1;
printf("%zu", sizeof(u));
}
8
4
1
13
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of this program?
#include <stdio.h>
int main()
{
typedef struct tag {
char str[10];
int a;
} tag;
tag h1, h2 = { "IHelp", 10 };
h1 = h2;
h1.str[1] = 'h';
printf("%s, %d", h1.str, h1.a);
return 0;
}
Error
IHelp 10
Ihelp 10
No Error ,No output
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of this program?
#include <stdio.h>
int main()
{
union test {
int i;
int j;
};
union test var = 10;
printf("%d, %d\n", var.i, var.j);
}
10,10
garbage values
Nothing
Compilation Error
20 questions
C Programming- Control statements
Quiz
•
University
19 questions
Lógica de programação C
Quiz
•
University
16 questions
UC_TM03_Arrays_Functions
Quiz
•
University - Professi...
20 questions
Python Code
Quiz
•
8th Grade - Professio...
20 questions
Programação de Computadores - Aula - 0
Quiz
•
University
25 questions
Python-Loops-Iterables
Quiz
•
12th Grade - University
25 questions
PSeInt
Quiz
•
University
25 questions
Introduction to Digital Communications
Quiz
•
University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade