July 5, 2021 in C and CPP
What is structured programming?
a) What is structured programming? Explain and give examples of relevant constructs
using pseudo-code. Highlight the advantages and disadvantages of structured
programming.
July 5, 2021 in C and CPP
a) What is structured programming? Explain and give examples of relevant constructs
using pseudo-code. Highlight the advantages and disadvantages of structured
programming.
July 5, 2021 in C and CPP
A. Macro B. One or zero C. Randomly
D. External E. Max F. True
G. String H. Automatic I. Extern
J. Register K. Dynamic L. SWITCH
M. Word Not Available N. EOF O. Arbitrary
P. typeDef
4.1 An external variable definition must not begin with storage class specifier ________.
4.2 A register variable is expected to be placed in the machine ________.
4.3 For ________ and static variables, initialisers must be constant expressions.
4.4 When a function calls itself, each invocation gets a fresh set of ________ variables,
independent of the previous invocation.
4.5 #define statement calls for simplest type of ________ substitution.
4.6 The function lseek provide a way to read or write a file in ________ order.
4.7 printf(“%.*s”, max, s) can be used to print at most ________ characters from a strings.
4.8 FILE is defined with a(n) ________ statement.
4.9 The process of allocating memory at run time is known as ________.
4.10 The function getchar( ) returns ________ when there is no more input character.
July 5, 2021 in C and CPP
Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein.
2.1 ‘C’ programs are converted into machine language with the help of an interpreter.
2.2 Every ‘C’ program must contain a main( ).
2.3 Putchar( ) is used only for single character input.
2.4 calloc(…) allocates a block of memory for an array of elements of a certain size.
2.5 A printf( ) statement can generate only one line of output.
2.6 A switch expression can be of any data type.
2.7 ‘While’ is an entry as well as exit controlled loop statement.
2.8 ‘C’ treats character string simply as arrays of characters.
2.9 A function in ‘C’ should have at least one argument.
2.10 sprintf(…) writes data to the character array whereas printf(…) writes data to the
standard output device.
July 5, 2021 in C and CPP
1.10 Regarding the scope of the variables; identify the incorrect statement:
A) automatic variables are automatically initialized to 0
B) static variables are automatically initialized to 0
C) the address of a register variable is not accessible
D) static variables cannot be initialized with any expression
July 5, 2021 in C and CPP
1.9 Given the piece of code
int a[50];
int *pa;
pa=a;
To access the 6th element of the array which of the following is incorrect?
A) *(a+5)
B) a[5]
C) pa[5]
D) *(*pa + 5)
July 5, 2021 in C and CPP
1.8 What does the following function print?
func(int i)
{if(i%2) return 0;
else return 1;}
main( )
{
int=3;
i=func(i);
i=func(i);
printf(“%d”, i);
}
A) 3
B) 1
C) 0
D) 2
July 5, 2021 in C and CPP
1.7 How is a variable accessed from another file?
A) via the extern specifier.
B) via the auto specifier.
C) via the global specifier.
D) via the pointer specifier.
July 5, 2021 in C and CPP
1.6 When applied to a variable, what does the unary “&” operator yield?
A) The variable’s address
B) The variable’s right value
C) The variable’s binary form
D) The variable’s value
July 5, 2021 in C and CPP
1.5 Suppose that x is initialized as:
short int x; /* assume x is 16 bits in size */
What is the maximum number that can be printed using printf (“%d\n”, x),
A) 127
B) 128
C) 255
D) 32,767
July 5, 2021 in C and CPP
1.4 char *ptr;
char myString[ ] = “abcdefg”;
ptr = myString;
ptr += 5;
The pointer ptr points to which string?
A) fg
B) efg
C) defg
D) cdefg