Worksheets2nd yr week 5 apt,reasoning, c prog
Total questions: 75
Worksheet time: 38mins
What does a pointer store?
Value of a variable
Address of a variable
Data type
Size of memory
Which operator is used to access the value stored at the address held by a pointer?
&
*
#
->
What will be the output? int a = 10; int *p = &a; printf("%d", *p);
Address of a
Garbage value
10
Compilation error
Which of the following correctly declares a pointer to an integer?
int p;
int *p;
*int p;
int &p;
What is a NULL pointer?
Pointer pointing to 0th location
Pointer pointing to garbage value
Pointer not pointing to any valid memory
Pointer pointing to itself
Which header file defines NULL?
stdio.h
stdlib.h
stddef.h
All of the above
What will be the output? int a = 5; int *p = &a; printf("%d", ++(*p));
5
6
Address of a
Error
Which pointer is used to access array elements?
File pointer
Function pointer
Array pointer
All pointers
If int *p;, what does p+1 represent?
Address increased by 1 byte
Address increased by size of int
Value incremented by 1
Compilation error
What will be printed? int arr[3] = {1,2,3}; int *p = arr; printf("%d", *(p+2));
1
2
3
Error
Pointer arithmetic depends on:
Compiler
Data type
Operating system
CPU speed
Which of the following is an invalid pointer declaration?
int *p;
float *fp;
char cp*;
double *dp;
A pointer that points to another pointer is called:
Wild pointer
Dangling pointer
Double pointer
Void pointer
What does void *p represent?
Pointer to void function
Generic pointer
Pointer to integer
Null pointer
What happens if a pointer is used without initialization?
Points to NULL
Points to 0
Causes compile-time error
Points to unpredictable location
Which function is used to allocate memory dynamically?
alloc()
malloc()
memalloc()
assign()
Which header file is required for dynamic memory allocation functions?
stdio.h
memory.h
stdlib.h
string.h
What does malloc() return if memory allocation fails?
0
-1
NULL
Garbage value
Which function allocates memory and initializes it to zero?
malloc()
calloc()
realloc()
free()
What is the correct syntax of malloc()?
malloc(size)
malloc(type)
malloc(sizeof(type))
malloc(type, size)
What will be the output of the following code? int *p = (int *)malloc(sizeof(int)); *p = 20; printf("%d", *p);
20
0
A garbage value
Compilation error
Which function is used to resize allocated memory?
resize()
malloc()
realloc()
calloc()
Which function is used to deallocate memory?
delete()
remove()
free()
clear()
What happens if free() is not used?
Program runs faster
No effect
Memory leak occurs
Compile-time error
After free(p), what should be done?
Use p normally
Set p = NULL
Reallocate automatically
Ignore pointer
A die is thrown once. What is the probability of getting a number greater than 4?
1/6
1/3
1/2
2/3
A card is drawn from a standard deck of 52 cards. What is the probability of getting a red card?
1/13
1/4
1/2
3/4
Two coins are tossed. What is the probability of getting at least one head?
1/4
1/2
3/4
1
What is the probability of getting a prime number when a die is thrown? (Prime numbers: 2, 3, 5)
1/6
1/3
1/2
2/3
A bag contains 5 red and 3 blue balls. One ball is drawn at random. What is the probability it is blue?
3/5
3/8
5/8
1/2
What is the probability of getting two heads when two coins are tossed?
1/4
1/2
3/4
1
From a deck of cards, what is the probability of drawing a king?
1/52
1/26
1/13
A number is chosen at random from 1 to 10. What is the probability that it is even?
1/10
2/5
1/2
3/5
If the probability of success is 0.65, what is the probability of failure?
0.35
0.65
1.65
0.5
A coin is tossed three times. What is the probability of getting exactly two heads?
1/8
3/8
1/2
3/4
A card is drawn at random. What is the probability it is neither a king nor a queen?
11/13
10/13
3/13
1/13
What is the probability of drawing a non-prime number from numbers 1 to 10?
1/2
3/10
2/5
7/10
If P(A) = 2/5, what is P(not A)?
2/5
3/5
Permutation (Q14–Q25) In how many ways can 5 different books be arranged on a shelf?
25
120
60
20
Permutation (Q14–Q25) How many permutations are possible using all letters of the word “CAT”?
3
6
9
12
Permutation (Q14–Q25) In how many ways can 3 people be selected and arranged from 5 people?
10
20
60
120
Permutation (Q14–Q25) How many 3-digit numbers can be formed using digits 1, 2, 3 without repetition?
3
6
9
27
Permutation (Q14–Q25) In how many ways can the letters of the word “APPLE” be arranged?
120
60
30
20
How many permutations of 4 objects taken 2 at a time are possible?
6
8
12
24
In how many ways can 6 people be seated in a row?
36
120
360
720
How many different numbers can be formed using digits 2, 3, 5 if repetition is allowed (3 digits)?
9
18
27
6
In how many ways can the letters of the word MATH be arranged?
12
16
24
32
How many permutations are possible of 7 objects taken all at a time?
504
720
5040
40320
In how many ways can 4 boys and 3 girls be arranged in a row?
144
504
720
5040
How many ways can the word "LEVEL" be arranged?
120
60
30
20
Choose the correct sentence.
He don't like coffee.
He doesn’t likes coffee.
He doesn’t like coffee.
He not like coffee.
Identify the part of the sentence that has an error: She is one of the best student in the class.
She is one
of the best
student
in the class
Choose the grammatically correct sentence.
Each of the players have arrived.
Each of the players has arrived.
Each player have arrived.
Each players has arrived.
Find the error in the sentence: Neither of the answers are correct.
Neither
of the answers
are
correct
Choose the correct option. A) She is more smarter than her sister. B) She is smarter than her sister. C) She is smartest than her sister. D) She is very smartest than her sister.
She is more smarter than her sister.
She is smarter than her sister.
She is smartest than her sister.
She is very smartest than her sister.
Identify the incorrect part: He is good in mathematics. A) He is B) good C) in D) mathematics
He is
good
in
mathematics
Choose the correct sentence. A) He has been working here since two years. B) He has been working here for two years. C) He is working here since two years. D) He worked here since two years.
He has been working here since two years.
He has been working here for two years.
He is working here since two years.
He worked here since two years.
Find the error: The teacher as well as the students were present. A) The teacher B) as well as C) the students D) were present
The teacher
as well as
the students
were present
Choose the correct sentence. A) She suggested me to apply. B) She suggested to me to apply. C) She suggested that I apply. D) She suggested me applying.
She suggested me to apply.
She suggested to me to apply.
She suggested that I apply.
She suggested me applying.
Identify the error: No sooner did he reached the station than the train left. A) No sooner B) did he C) reached
No sooner
did he
reached
Choose the correct option.
The news are very shocking.
The news is very shocking.
The news were very shocking.
The news have been shocking.
Find the incorrect part: He is senior than me in this office.
He is
senior
than
me
Choose the grammatically correct sentence.
I prefer tea than coffee.
I prefer tea to coffee.
I prefer tea over than coffee.
I prefer tea more than coffee.
If CAT is coded as DBU, how is DOG coded?
EPH
EOG
DPH
EPH
If A = 1, B = 2, ... Z = 26, what is the code for BAT?
23
25
24
22
If PEN is coded as QFO, how is INK coded?
JOL
JML
JNK
JKL
If MONDAY is coded as NPOEBZ, how is SUNDAY coded?
TVOEBZ
TVOEBZ
TVOEBZ
TVOEBZ
If 246 is coded as 135, how is 579 coded?
468
468
468
468
If TREE is coded as UQGG, how is LEAF coded?
MFBG
MDBG
MEBG
MDFG
If BOOK is written as CPPL, how is WORD written?
XPSF
XPRF
WPSD
XPSE
If 3 → 9, 4 → 16, 5 → 25, then 7 → ?
35
42
49
56
If SOUTH is coded as TPUWI, how is NORTH coded?
OPSUI
OPSUI
OPSUI
OPSUI
If TABLE is coded as 20-1-2-12-5, how is CHAIR coded?
3-8-1-9-18
3-7-1-9-18
3-8-1-9-17
3-8-1-8-18
If 1 = A, 2 = B, ..., 26 = Z, what is the code for 19-21-14?
SUN
RUN
FUN
SON
If CLOCK is coded as DMPDL, how is WATCH coded?
XBUFK
XBUCI
XBVFK
XBVFI
