0% found this document useful (0 votes)
7 views

Programming Fundamentals Important Programs

The document outlines a series of programming tasks for a C++ fundamentals lab, focusing on the use of pointers and memory management. It includes specific questions requiring the implementation of programs that demonstrate pointer manipulation, memory address display, and array handling. Each question is accompanied by a space for code and expected output, indicating a practical approach to learning C++ programming concepts.

Uploaded by

abdsyd21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming Fundamentals Important Programs

The document outlines a series of programming tasks for a C++ fundamentals lab, focusing on the use of pointers and memory management. It includes specific questions requiring the implementation of programs that demonstrate pointer manipulation, memory address display, and array handling. Each question is accompanied by a space for code and expected output, indicating a practical approach to learning C++ programming concepts.

Uploaded by

abdsyd21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

JANUARY 11, 2025

PROGRAMMING
FUNDAMENTALS LAB
LAB TASKS 11

NAME: ABDULLAH SYED


REG NO: 240201083
CS-05(A)
QUESTION 1:
Write a C++ program that defines an integer variable var1 and
a pointer Ptr that points to var1. Assign and print value to
var1, then assign and print a new value to var1 using Ptr.

CODE:

OUTPUT:
QUESTION 2:
What will be the output of the following code?
#include<iostream> using namespace std; void main() { int
nNumber; int *pPointer; nNumber = 15; pPointer =
&nNumber; cout<<"nNumber: "<<nNumber <<"\npPointer:
"<<pPointer <<"\n*pPointer: "<<*pPointer <<"\n&nNumber:
"<<&nNumber <<"\n&pPointer: "<<&pPointer
<<"\n&*&*pPointer: "<<&*&*pPointer <<"\n*&*&*pPointer:
"<<*&*&*pPointer<<endl;

CODE:

OUTPUT:
QUESTION 3:
Write a C++ program that use pointers to swap two integer
values.

CODE:

OUTPUT:
QUESTION 4:
Write a C++ program that inputs four floating-point values
and displays the memory address of all the values using
pointers. Also, display the values using pointers.

CODE:

OUTPUT:
QUESTION 5:
Write a program that inputs a string value from user and
displays it using pointer.

CODE:

OUTPUT:
QUESTION 6:
Write a C++ program that: Creates an array of integers with 5
elements. Uses a pointer to sum the elements of the array.
Prints the sum of the array.

CODE:

OUTPUT:
QUESTION 7:
Write a C++ program that: Creates an array of integers with 10
elements. Uses a pointer to traverse through the array and
print each element. Uses pointers to reverse the array and
print the reversed array.

CODE:

OUTPUT:
QUESTION 8:
Write a C++ program that: Defines a function swap() that
takes two integer pointers and swaps the values of the
integers. In the main() function, initialize two integer variables
and pass their addresses to the swap() function to swap their
values. Print the values before and after the swap.

CODE:

OUTPUT:

You might also like