0% found this document useful (0 votes)
3K views2 pages

CodeBuzz 1

It is a multiple choice questions

Uploaded by

v41047827
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views2 pages

CodeBuzz 1

It is a multiple choice questions

Uploaded by

v41047827
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GOVERNMENT COLLEGE OF ENGINEERING SALEM – 11.

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING


ELECTROFEST’24
CODEBUZZ-1

NAME: REG.NO.: YEAR:

1. Which of the following is a valid c) You cannot use pointers to access


identifier in C? structure members when
a) total-amount dynamically allocated.
b) 2total d) Both a and b.
c) total2
d) @total
7. True or False: In a for loop, the
increment expression can be any valid
2. True of False: In C, keywords can be C expression, including function calls.
used as variable names. a) True
a) True b) False
b) False

8. Which functions is used to open a file


3. What is the correct syntax for for reading in C?
declaring a float variable? a) fopen(filename,”w”);
a) float x; b) fopen(filename,”r”);
b) float x = “5”; c) open(filename);
c) float int x; d) fileopen(filename,”r”);
d) float x 5;

9. What will be the output of the following


4. Which of the following is an invalid code?
identifier in C? int i = 0;
a) myVar123 While(i<3){
b) _totalAmount i++;
c) Int printf(“%d”,i);
d) total_Amount }
a) 1 2 3
b) 0 1 2
5. True or False: Variable names in C can c) 1 2 3 4
include special characters like ‘@’ or d) 2 3 4
‘#’.
a) True 10. True or False: In C, a structure can
b) False contain arrays and other structures.
a) True
b) False
6. Which of the following statements is
true about dynamic memory allocation
in structures? 11. Which of the following is the correct
a) You can allocate memory for syntax for defining a structure in C?
structure members using malloc() a) struct car {char name[20]; int
or calloc(). speed;};
b) The memory allocated using b) structure car {char name[20]; int
malloc() for a structure needs to be speed;};
freed using free(). c) struct {char name[20]; int speed;}
d) structure name {int a; float b;}
12. What will happen if you try to open a p++;
non-existent file in read mode? printf("%d", *p);
a) The file will be created. a) 10
b) The program will terminate with an b) 20
error. c) 30
c) The file will be opened without any d) Compilation Error
error.
d) None of the above
17. True or False: You can use realloc() to
increase or decrease the size of
13. Which of the following operations can dynamically allocated memory.
you perform on a structure in C? a) True
a) Compare two structures using == b) False
operator.
b) Access individual structure
members using the dot operator . 18. What will be the result of the following
c) Directly assign one structure to code?
another if they are of the same type int a = 5;
d) All of the above int *p = &a;
free(p);
printf("%d", a);
14. What will happen if you try to access a a) 5
memory location through an b) Garbage value
uninitialized pointer in C? c) The program will crash
a) The program will crash. d) Undefined behavior
b) It will cause undefined behaviour.
c) The program will output garbage
values. 19. Which of the following statements is
d) It will compile and run without any correct about pointer arithmetic in C?
issues. a) Adding an integer to a pointer
moves the pointer by that integer
value in bytes.
15. What is the output of the following b) Adding an integer to a pointer
code? moves the pointer by that integer
int x = 10; value in memory locations
int *ptr1, *ptr2; corresponding to the data type it
ptr1 = &x; points to.
ptr2 = ptr1; c) Subtracting two pointers gives the
*ptr2 = 20; absolute difference in memory
printf("%d", x); addresses.
a) 10 d) None of the above
b) 20
c) Compilation Error
d) Undefined behaviour 20. Which of the following is the correct
syntax for dynamically allocating
memory for an integer?
16. What is the output of the following a) int *ptr = (int*)malloc(sizeof(int));
code? b) int *ptr = malloc(sizeof(float));
int arr[3] = {10, 20, 30}; c) int ptr = malloc(int);
int *p = arr; d) malloc(sizeof(int))

You might also like