0% found this document useful (0 votes)
14 views4 pages

Graded Assignment 6

The document outlines the lab sheet for CSD101 at Shiv Nadar Institution of Eminence for Spring 2024, detailing lab procedures, assignment deadlines, and grading policies. It includes specific programming tasks involving pointers, such as finding maximum and minimum values in an array and creating a calculator using function pointers. Additionally, it lists practice problems for self-learning and emphasizes the importance of code correctness and originality in submissions.
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)
14 views4 pages

Graded Assignment 6

The document outlines the lab sheet for CSD101 at Shiv Nadar Institution of Eminence for Spring 2024, detailing lab procedures, assignment deadlines, and grading policies. It includes specific programming tasks involving pointers, such as finding maximum and minimum values in an array and creating a calculator using function pointers. Additionally, it lists practice problems for self-learning and emphasizes the importance of code correctness and originality in submissions.
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/ 4

Shiv Nadar Institution of Eminence, Delhi, NCR

Lab sheet for CSD101 (Introduction to computing and Programming)

Semester of Implementation: Spring, 2024

Instructors: Dr. Snehasis ([email protected]), Dr. Himani


([email protected] ), Dr. Sheel ([email protected])

Instructions:

1. Once you complete the assignment, please show it to the TA.


2. Lab will start in exact time. Students should enter the lab and take a seat 5 minutes
before.
3. It is recommended to use LINUX platform for execution of the program.
4. Batch change to show the assignments WILL NOT be allowed.
5. Malpractice (in ANY form) will attract heavy penalties.

Lab Assignment 6

Deadline: 30/03/2025 Sunday


Total Marks: 5*2 = 10

Objective: Programs based on Pointers.

Steps to run C program


Step 1: gedit filename.c

Step 2: Compiling using GCC compiler

We use the following command in the terminal for compiling our filename.c source file

$ gcc filename.c –o filename


Step 3: Executing the program

After compilation executable is generated and we run the generated executable using the
below command.

$ ./filename

Graded Problems (For Submission)

Question 1: Find Maximum and Minimum Using Pointers

Write a C program to:


• Accept n numbers from the user.
• Use a pointer to find the maximum and minimum values in the array.

Expected Input/ Output:

Enter the number of elements: 4


Enter the elements: 10 50 30 5
Maximum = 50
Minimum = 5

Question 2: Calculator using Function Pointers

Write a C program that implements a simple calculator performing various mathematical


operations using function pointers. The operations to implement are addition, subtraction,
multiplication, and division. The user would need to specify which operation they would like
to perform by entering the corresponding operator ‘+’, ‘-‘, ‘*’, and ‘/’.

Input and Output:

Enter first number: 9


Enter second number: 2
Enter an operator (+, -, *, /): /

Result: 4.50

Enter first number: 8


Enter second number: 2
Enter an operator (+, -, *, /): +

Result: 10
Practice Problems (Not for Grades, but Recommended)

P1: Print Address of a Variable

Write a C program that:


• Takes an integer input from the user.
• Uses a pointer to store its address.
• Prints the address of the variable using the pointer.

P2: Pointer and String Manipulation

Write a C program to:


• Accept a string from the user.
• Print the string using a pointer.
• Find the length of the string using a pointer.

P3: Swapping Two Numbers Using Pointers

Write a C program to swap two numbers using pointers.


• Accept two integers from the user.
• Use pointers to swap their values.
• Print the values before and after swapping.

P4: Count Even and Odd Numbers Using Pointers

Write a C program that:


• Takes n numbers as input.
• Uses pointers to count how many numbers are even and how many are odd.

P5: Reverse a String Using Pointers

Write a C program that:


• Accepts a string from the user.
• Uses pointers to reverse the string.

P6: Swap Two Numbers Using Pointers Without a Temporary Variable

Modify P3: swap program so that it swaps two numbers without using a temporary variable
using pointers.

Submission Guidelines
1. Submit your solutions for Q1 and Q2 via Blackboard.
2. Use meaningful function names and include comments to explain your code.
3. Practice problems are for self-learning and do not require submission.

Grading Policy:-
1. No marks for incomplete programs.
2. No marks for a program that does not compile.
3. No marks for a program that does not give correct output for any input.
4. Half marks for a program which gives correct output only for a specific set of inputs, but not
generally for all inputs.
5. Full marks for a program that gives correct output for any input.

- All submissions are subject to plagiarism checks. Any case of plagiarism will be dealt
with severely.

You might also like