Question: Plss help me with these questions.. (everything is C++ software) Question 2b (2 marks) Based on the following code write the statement that will display

 Plss help me with these questions.. (everything is C++ software) Question

2b (2 marks) Based on the following code write the statement that

will display the address of variable number1. int main { int number1=1;

return 0; Question 3 (4 marks) (a) Identify and correct the errors

in each of the following: () if (x==p) (ii) while (a>b) (a

= b; } [2 marks] (b) What is wrong and how to

fix the following code, assume m is initialized to 10 and the

program is expected to calculate the summation of the integer from 10

down to 0. while ( m >= 0) sum += m; [2

marks] Question 4a (2 marks) Based on the following code, answer the

following questions #include #include #include void maino printf("%d", _(i)); return; } a-i)

Write the missing code in (i) to print the random number between

1 to 20 [1 mark] a-ii) Add a code to ensure the

random number generated in question (a-i) is different every time the random

number is produced [1 mark] Question 4b (2 marks) The following code

calculates the volume of a cube with height = 3. Fill in

the missing code for (i) and (ii) #include void main( { int

cube Height = int cubeVolume = 0; (ii) printf ("%d",cubeVolume); return; }

Question 5a (2 marks) Find the error(s) in each of the following

Plss help me with these questions.. (everything is C++ software)

Question 2b (2 marks) Based on the following code write the statement that will display the address of variable number1. int main { int number1=1; return 0; Question 3 (4 marks) (a) Identify and correct the errors in each of the following: () if (x==p) (ii) while (a>b) (a = b; } [2 marks] (b) What is wrong and how to fix the following code, assume m is initialized to 10 and the program is expected to calculate the summation of the integer from 10 down to 0. while ( m >= 0) sum += m; [2 marks] Question 4a (2 marks) Based on the following code, answer the following questions #include #include #include void maino printf("%d", _(i)); return; } a-i) Write the missing code in (i) to print the random number between 1 to 20 [1 mark] a-ii) Add a code to ensure the random number generated in question (a-i) is different every time the random number is produced [1 mark] Question 4b (2 marks) The following code calculates the volume of a cube with height = 3. Fill in the missing code for (i) and (ii) #include void main( { int cube Height = int cubeVolume = 0; (ii) printf ("%d",cubeVolume); return; } Question 5a (2 marks) Find the error(s) in each of the following program segments. Write the corrected code for each error. i) The following statement should print the string Happy Birthday printf("%s ", 'Happy Birthday); of ion ii) The following statement should print the characters O and K: printf("%s%s ", '0', 'K'); Question 5b (2 marks) Write the missing code that prints the strings "Hello World" in right justified and left justified respectively. #include int main() { printf("Right Justified strings "); ( printf("Left Justified strings "); (ii) return 0; Question 6a (2 marks) Create a function prototype for the following function:- void printbalance inta) { printf("Your balance is : %d", a); } Question 6b (2 marks) What is the output of the following code segment : int main() { printf(Total = %d", calculate(5)); } int calculate( int x) { if(x int main() { int p; (1) p = 7; return 0; Question 8b (2 marks) Are the expressions *ptr++ and + + *ptr same? Explain your answer. Question 8c (2 marks) What is the output of the program below? #include int main( { int all= {1,2,3,4,5), *p: pra; ++*p; printf("%d", *p); p+=2; printf("%d", *p); return 0; Question 8d (2 marks) What is the output of the program below? #include int main() { int *ptr, a=10; ptr = &a; *ptr += 1; printf ("%d, %d", *ptr, a); return 0; } Question 9 (8 marks) (a) What is the output of the following statement? printf( *%u", strspn( "Cows like to moo.", "Ceiklosw")); (b) What is the output of the code below? char a[100] = "compute", b[100] = "science", c[100], *ptr; printf("%s", strcpy( c, b)); (c) Below is the program to read a string from user (Example, Albert Alexander) and display it out to user Fill in (i) and (ii). #include #include int main() { char name[30]: printf("Enter name: "); :// (to read string) printf("Name: "); (i) // (to display string) return 0; } (d) Write a C statement to append 10 characters from the string in s2 to the string in s1. Question 10a (2 marks) Explain TWO (2) of the components of the structure below: struct TestStructure{ int Age; char Name[20]; } p1; Question 10b (2 marks) Given segments of Cappuccino program written in C as in Figure 1, complete the program to produce an output as illustrated in Figure 2 below: #include #include /*Declare a structure Cappuccino that contains number of sugar and cup size/ (ii) }; int main() /* Declare a variable capp of type Cappuccino / struct Cappuccino capp: /* Assign 2 sugar to variable capp/ (v) /* Set the size of variable capp to medium/ capp.size M printf("zeanCappuccino Info ---== "); printf("No. of Suggar Added : %d ", capp.noSugar); /Display the cup size of capp/ (v) return 0; Figure 1. Segments program of Cappuccino.c - Cappuccino Info *** No. of Suggar Added : 2 Cup size : M Question 11a (2 marks) Write a C statement to read a record for stud of type Student structure from a binary file using a file pointer *fp. Question 11b (2 marks) Complete the C program in Figure 3 below to read a series of integer numbers from a sequential file namely ExamFile.txt. Hinclude int main() /*Create a pointer of type IILE / /*Open EzanFile.txt in read mode / (11) /*To verify whether the file is opened successfully/ if (111) paintf ("Error!"); exit (1); > int ReadNum, ii /*Read 10 integers from ExamFile.txt file/ /*and print the integers on the screen printf("The 10 integers in the files are : "); for(i=1; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!