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 name, age and salary of two employees from the user. Print the information of employee with more salary using pointers and structures.
Note:-
Need proper indent and output
1)
#include<iostream>
using namespace std;
int main()
{
char a='Y';
float b=10.2;
char *pa=&a;
float *pb=&b;
cout<<"Address of char variable is:
"<<&pa;
cout<<"\nAddress of float variable is:
"<<&pb;
cout<<"\n\nValue of char variable is:
"<<*pa;
cout<<"\nValue of float variable is:
"<<*pb;
*pb+=2;
cout<<"\n\nValue of float variable after adding
2 is: "<<*pb;
cout<<"\nAddress of char variable is:
"<<&pa;
return 0;
}
output:-

2)
#include<iostream>
using namespace std;
int main()
{
int a[5];
int *p=a;
cout<<"Enter the 5 elements in the
array:-\n";
for(int i=0;i<5;i++)
{
cin>>a[i];
}
cout<<"\n\nReverse of array is: ";
for(int i=4;i>=0;i--)
{
cout<<*(p+i)<<"
";
}
return 0;
}
output:-

3)
#include<iostream>
using namespace std;
struct employee
{
string name;
int age;
float salary;
};
int main()
{
employee e[2];
float
*sal1=&e[0].salary,*sal2=&e[1].salary;
for(int i=0;i<2;i++)
{
cout<<"Enter the name of
"<<i+1<<" employee: ";
cin>>e[i].name;
cout<<"Enter the age of
"<<i+1<<" employee: ";
cin>>e[i].age;
cout<<"Enter the salary of
"<<i+1<<" employee: ";
cin>>e[i].salary;
cout<<"\n";
}
if(*(sal1)>*(sal2))
{
cout<<"First employee has
higher salary. Details are:-\n";
cout<<"Name of employee:
"<<e[0].name;
cout<<"\nAge of employee:
"<<e[0].age;
cout<<"\nSalary of employee:
"<<e[0].salary;
}
else
{
cout<<"Second employee has
higher salary. Details are:-\n";
cout<<"Name of employee:
"<<e[1].name;
cout<<"\nAge of employee:
"<<e[1].age;
cout<<"\nSalary of employee:
"<<e[1].salary;
}
return 0;
}
output:-

Pointer tasks: ( In C++ ) 1. Write a program to store the address of a...
1. Write a C++ Program to display address of elements of an array using both array and pointers 2. Write a C++ Program to insert and display data entered by using pointer notation. 3. Write a C++ Program to access Array Elements Using Pointer
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...
Write in C. Simple Program (beginner)
Assignment: Write a program Character Pointers and Functions. (like program #5-5). Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count. <END>
Please include function in this program
Write a C program that will calculate the gross pay of a set of employees utilizing pointers instead of array references. You program should continue to use all the features from past homeworks (functions, structures, constants, strings). The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and...
Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...
in C language we need to find the following :
EXERCISE 3: 1. Write the definition of a structure named employee that contains character array members for an employee's first and last names, an int member for the employee's age, a char member that contains 'M' or 'F' for the employee's gender, and a double member for the employee's hourly salary. 2. Using the above mentioned definition, write a C program that asks a user to enter the values of...
write the program in c++
Pointen & A???ys: Write u function that is passed a pointer to a float array, and the size the array as an int. The function should return a pointer to the maximum element in the array The function should be: int *maxp(float* ap, int size) Write a main() program to lest the function with different input arrays. Grading Criteria (1 point each): Uses cin/cout correct function definition prompts user for input, reads it in correct...
l ask Write a C++ program that accomplishes the following tasks 1. Write a function that finds the average of current element and the next element in given array named as "elements" and stores the new found averages into another array called "averageArray". Note: For the last element you can just divide the value of last element by 2 Write a function that takes both the given array and average array you just created along with a variable "productofArrays" using...
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.