Question

I need help with my C coding homework. If possible can you please comment to help me understand whats going on in the code. Thanks in advance. Create a C program (3 points): o At the top of the file include the following comments: Your name The purpose (core concept found below) of the program The date created o Create two int variables: Initialize each to different values. o Create three pointers: Point the first two pointers to the first variable Point the third pointer to the second variable Display the memory addresses and values of both variables. Include an appropriate output messages. o Display the contents of all pointers. Include an appropriate output messages. o Display the values of the memory location each pointer points to oChange the value of the first variable. o Display the value of the first variable. Include an appropriate output message. Display the values of the memory locations for the pointers that point to the first variable. Include an appropriate output message oUse the third pointer to change the value at the memory location the third pointer points to. o Display the value of the memory location the third pointer points to. Include an appropriate output message. o Display the value of the second variable. Include an appropriate output message. Compile and run your code. Submit your source code as a plain text file with a .c extension. Make sure it compiles without error before submitting it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Gaurav ponkiya
//Core concept of this program is to understand pointer
//09-nov-18
#include<stdio.h>
int main()
{
int a=5,b=6;//Two int variable with different values
int *p1,*p2,*p3;
p1=p2=&a;
p3=&b;
printf("Initial value of two integers are a=5,b=6\n");
printf("Memory Address=%d\nValue=%d\n",p1,*p1);

printf("Memory Address=%d\nValue=%d\n",p3,*p3);
printf("Content of all pointers\nFirst pointer points to->%d\nSecond pointer points to->%d\nthird pointer points to->%d\n",*p1,*p2,*p3);
printf("Memory location points by Each pointer\np1=%d\np2=%d\np3=%d\n",p1,p2,p3);
a=8;//change the value of first variable
printf("value of first variable=%d\n",*p1);
*p3=10;//changing value which is pointed by third pointer
printf("Memory location the third pointer points to is %d\n",p3);
printf("Value of second variable=%d",*p3);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
I need help with my C coding homework. If possible can you please comment to help...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please code in c 1. Write a program which does the following: Declare and initialize three...

    Please code in c 1. Write a program which does the following: Declare and initialize three pointers. One points to an integer, one points to a float and one points to a character variable Ask the user to enter appropriate values for these variables. Output the values to the screen by accessing the variables directly and then by using pointer references. Print the address of each variable. Modify the variables by performing any arithmetic operation only using pointer refer- ences...

  • Lab 8 CS102 Lab 8 Hands on programming with Pointers The goal of this lab exercise...

    Lab 8 CS102 Lab 8 Hands on programming with Pointers The goal of this lab exercise is to apply the knowledge of pointers and File input output operations. Program 1 Short description: Declare, initialize and use pointers for different data types. Detailed Description: Declare 4 variables of type's int, float, double and char respectively and initialize them to some logically correct values. Declare pointers to all these variables. Initialize the pointers to point to these variables respectively Print the values...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • Main topics: Files Program Specification: For this assignment, you need only write a single-file ...

    C program Main topics: Files Program Specification: For this assignment, you need only write a single-file C program. Your program will: Define the following C structure sample typedef struct int sarray size; the number of elements in this sanple's array floatsarray the sample's array of values sample Each sample holds a variable number of values, all taken together constitute a Sample Point Write a separate function to Read a file of delimited Sample Points into an array of pointers to...

  • I need help with my coding for C++! The goal of this is to calculate the...

    I need help with my coding for C++! The goal of this is to calculate the total cost of a product by combining the products price and the amount of tax, then display it to the user. The numbers we have to test out is 100 for the price and 8.25 for the percentage. When I test is out, the formula works but it isn't rounding the 108.25 to 108.3, which is the total price we are supposed to display...

  • I need help doing the requirements listed below. Please don't delete comments. #include #include #include #include...

    I need help doing the requirements listed below. Please don't delete comments. #include #include #include #include "Imager.h" /// 5 points : The program compiles without errors and warnings /// 5 points : The program operates correctly using namespace std; int main() { /// 2 points: Create an instance of two integers called "inX" and "inY". /// 2 points: Create an instance of the Imager class called "myImager". /// 2 points: Create a file input stream called "fileInStream". /// 2 points:...

  • C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use...

    C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use a simple node that has a pointer to a Node. The data for the Node will be a single data member of type char. You will build a structure where the last node you add will point to the first node created, i.e. it will be a circular linked structure. You will create a program that stores characters provided by the user, stored in...

  • Need help about C PROGRAMMING,, pls use only C LANGUAGE.., yea so im doing this exercise...

    Need help about C PROGRAMMING,, pls use only C LANGUAGE.., yea so im doing this exercise as a practice for c programming, could someone do this as well so i could compare if my code makes makes sense and to see and help correct the errors im getting right now.. Any helpful help would be appreciated.. Pointers &Pointer arithmetic Memory allocation and freeing Main topics: Exercise This lab is designed to give you practice working with pointers and memory allocation...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • Can anyone help me with my C hw? Exercise 3 You will write a new program...

    Can anyone help me with my C hw? Exercise 3 You will write a new program that combines dynamically allocating an array and saving that array to a file. These are the tasks your program must perform Open an output file named "data.txt" and prepare it for writing in text mode o If the file handle is NULL, quit the program o By default, it is created and stored in the same directory as your source code file Prompt the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT