July 6, 2021 in C and CPP
Which is the valid statement in C?
1.2 Which is the valid statement in C?
A) #define half(x) ((x)/2.0)
B) #define STREQ(s1,s2) (strcmp((s1),(s2))==0);
C) #define MAX = 5
D) #define INTEREST 5, LOAN 5000
July 6, 2021 in C and CPP
1.2 Which is the valid statement in C?
A) #define half(x) ((x)/2.0)
B) #define STREQ(s1,s2) (strcmp((s1),(s2))==0);
C) #define MAX = 5
D) #define INTEREST 5, LOAN 5000
July 6, 2021 in C and CPP
1.1 What will be the output of the following code segment (assuming sizeof(int) returns 4)?
int i = 0x1 << sizeof(int) * 8 – 1;
printf(“\n%x”, i);
i = i >> sizeof(int) * 8 – 1;
printf(“%d”, i);
A) 0x8000000 - 1
B) 80000000 - 1
C) -1 0x80000000
D) -1 80000000
July 5, 2021 in C and CPP
c) ‘C’ compiler supports many pre-processor commands. Write their names.
July 5, 2021 in C and CPP
b) What is an indirection operator? Explain its usage to access a multidimensional array
element. Illustrate your answer by an example.
July 5, 2021 in C and CPP
a) Give the main advantage of storing data as a file. Describe various ways in which data
files can be categorized in ‘C’. Illustrate by examples.
July 5, 2021 in C and CPP
c) Develop a program to multiply two matrices with sizes 3x4 and 4x5. Your program
should take care of the fact that no element of either matrix can be negative. Include
appropriate documentation.
July 5, 2021 in C and CPP
b) How are one-dimensional and two-dimensional arrays stored in computer memory?
Illustrate with an example.
July 5, 2021 in C and CPP
a) How does an array differ from a structure? Give and explain the syntax of array and
structure as defined in ‘C’.
July 5, 2021 in C and CPP
b) Write a function that will compute
Y = X^n
Where Y and X are floating point numbers and n is an integer number. Use this function
and print the output
X n Y
… … …
Check for possible exceptions that may occur during computations with regard to the
magnitude of computed values.
July 5, 2021 in C and CPP
a) Develop loops using
i) While statement
ii) Do-while statement
iii) For statement
that will calculate the sum of every third integer, beginning with k=2 for all values of
k <= 100.