Question

1. Write a program which does the following: Declare and initialize three pointers. One points to an integer, one points to a

Please code in c

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

#include<stdio.h>
int main(){
int i;
float f;
char c;

int *iPtr = &i;
char *cPtr=&c;
float *fPtr=&f;
printf("Enter character: ");
scanf("%c",&c);
printf("Enter integer: ");
scanf("%d",&i);

printf("Enter decimal: ");
scanf("%f",&f);
printf("Printing Directly\n");
printf("%d\n",i);
printf("%f\n",f);
printf("%c\n",c);
printf("Printing using pointers\n");
printf("%d\n",*iPtr);
printf("%f\n",*fPtr);
printf("%c\n",*cPtr);

printf("Address of variables\n");
printf("%u\n",iPtr);
printf("%u\n",fPtr);
printf("%u\n",cPtr);

*iPtr=*iPtr+10;
*cPtr=*cPtr+5;
*fPtr=*fPtr+5.5;
printf("Printing after changing \n");
printf("%d\n",*iPtr);
printf("%f\n",*fPtr);
printf("%c\n",*cPtr);

printf("Address of variables\n");
printf("%u\n",iPtr);
printf("%u\n",fPtr);
printf("%u\n",cPtr);


}

Enter character: A Enter integer: 10 Enter decimal: 12.5 Printing Directly 12.500000 Printing using pointers 12.500000 Addres

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Please code in c 1. Write a program which does the following: Declare and initialize three...
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
  • 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...

  • Write a complete C program that does the following: . o Declare a and b as...

    Write a complete C program that does the following: . o Declare a and b as character variables. Initialize a to this value: 127 o Declare c as an unsigned character variable o Multiply a by 2 and store the result in variable b. o Multiple a by 2 and store the result in variable c. Print the values of a, b, and c. Use the %d specifier in each case. Declare d as an integer variable. Initialize d to...

  • Pointer tasks: ( In C++ ) 1. Write a program to store the address of a...

    Pointer tasks: ( In C++ ) 1. Write a program to store the address of a character variable and a float variable. • Print the address of both variables. • Print the values of variable using dereference operator. • Add 2 in float value using pointer. • Print address of character variable using reference operator. 2. Write a program that takes 5 elements in an array and print them in reverse order using pointers. 3. Write to program that takes...

  • Please Answer with C code. Will rate! Thanks 1) Write a program in C to demonstrate...

    Please Answer with C code. Will rate! Thanks 1) Write a program in C to demonstrate the use of &(address of) and *(value at address) operator. #include <stdio.h> void main() { int m=300; float fx = 300.60; char cht = 'z'; int *pt1; float *pt2; char *pt3; pt1= &m; pt2=&fx; pt3=&cht; a) print the address of variables (m, fx, cht) use & operation b) print the value at address of variables (m, Fx, cht) use & and * c) print...

  • Question 16 (4 points) Write a complete C program that declares four variables of type integer...

    Question 16 (4 points) Write a complete C program that declares four variables of type integer (i.e integer variables) and four variables of type pointer to integer (i.e. integer pointers). Assign the addresses into the pointers. Using the indirection operator with a pointer, assign the values 1, 2, 3, and 4 into the four integers. (Use the indirection operator with the pointers to write the integer values.) Your program should write the addresses and values of all eight variables to...

  • Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and...

    Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and intVar4. 2. Initialize intVar1 to the value 4; initialize intVar2to the value 5. 3. Declare four more integer variables. exp1, exp2,exp3, and exp4. 4. Declare a character variable charVar. 5. Assign the value of each expression below to variables exp1and exp2 respectively: exp1= intVar1 + ((5 * intVar2) / (3 * intVar1)); exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1; 6....

  • Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an...

    Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an int variable and int array with four elements in the main program. Initial values for the intvariable and int array are hardcoded in the program. Declare an int pointer in the main program.Program shows the values of the integer variable and integer arrayelements. Program shows the addresses of the variable and each integer array element. Store addresses inpointers temporarily prior to displaying. The addresses...

  • I need help with my C coding homework. If possible can you please comment to help...

    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...

  • Write a complete program that: 1) declares two local integers x and y 2) defines a...

    Write a complete program that: 1) declares two local integers x and y 2) defines a global structure containing two pointers (xptr,yptr) and an integer (z) 3) Declares a variable (mst) by the type of previous structure 4) requests the values of x and y from the user using only one scanf statement 5) sets the first pointer in the struct to point to x 6) sets the second pointer in the struct to point to y 7) uses the...

  • Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You...

    Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...

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