Programming Code Languages Quiz Questions and Answers

1.  Debug and Run the following code. This code is about the handling of pointers.  Create the Output the same as the given sample. Call your instructor to confirm the results then copy the screenshot of your code and output in the blank space below. (5 marks)

 

#include<stdio.h>

int main() {

       int pc;// consider pc as a pointer

       int c;   // consider c normal integer variable

       c = 22;

       printf("\n Address of c:%c\n", *c);

       printf(" Value of c:%d", c);

       pc = &c;

       printf(" pc:%d\n", pc);

       printf(" pc:%d\n\n", *pc);

       c = 11;

       printf(" pc:%u\n", pc);

       printf(" pc:%d\n\n", *pc);

       *pc = 2;

       printf(" Address of c:%c\n", &c);

       printf(" Value of c:%d\n\n", c);

      {

2.   Modify the following code in C to be able to read your first and last name up to a maximum 30 characters. Use Character type of array, with getting char and for loop to read from input character by character then print out on the screen only First and Last Name by using Character type of array, with for loop. Call your instructor to confirm the results then copy the screenshot of your code and output in the blank space below. (5 marks)

Output:

David James

 

starter code:

 

#include<stdio.h>

void main()

{

       inti = 0;

       char name[20];

       printf("\nEnter the Name : ");

       while ((name[i] = getchar()) != '\n')

              i++;

       getch();

}

3.  What is the output of the following code please explain it. Call your instructor to confirm the results then copy the screenshot of your code and output in the blank space below. (5 marks) (5 marks)

#include<stdio.h>

void main()

{

       int a[3] = { 1, 2, 3 };

       int *p = a;

       printf("%p\t%p", p, a);

       }

#include<stdio.h>

void main()

{

       char *s = "ETEC128";

       char *p = s;

       printf("%c\t%c", p[0], s[4]);

       }

Get Assignment Help from Subject Matter Experts 24/7

Obtain expert assistance with assignments and homework when you need it most. Receive well-researched, AI-free unique solutions to earn better grades.

Chat Now

Great

Academic Solution

356380+

Orders
Delivered

4.9/5

5 Star
Rating

3000+

Professional
Experts

Amazing Features

Plagiarism Free
Best Price
100% Money Back
Top Quality
On Time Delivery
24 x 7 Support

NEED ASSIGNMENT HELP?

Find More Assignment Help

Boost Your MBA Grade!

MBA Assignment Help Australia

CDR for Engineers Career

cdr for australia

Browse Similar Services

 

Get Expert Assistance!

hire assignment expert

Best Deals on Assignments!

Book my Assignment

On Time Delivery

100% Plagiarism free work

Free Referencing Done

Our Experts

get expert assistance
Top