0% found this document useful (0 votes)
30 views9 pages

Lab 6

This document provides instructions for Lab 6 assignment on structures and 2D arrays. Students are asked to write a C program to calculate the number of equilateral triangles that can be formed from 16 points arranged in a 4x4 matrix. The program should include functions to input the points, calculate distance between points, check if 3 points form an equilateral triangle, and count the total equilateral triangles recursively or non-recursively. Code copying is strictly prohibited and submissions must be made on the course Moodle page by the due date.

Uploaded by

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

Lab 6

This document provides instructions for Lab 6 assignment on structures and 2D arrays. Students are asked to write a C program to calculate the number of equilateral triangles that can be formed from 16 points arranged in a 4x4 matrix. The program should include functions to input the points, calculate distance between points, check if 3 points form an equilateral triangle, and count the total equilateral triangles recursively or non-recursively. Code copying is strictly prohibited and submissions must be made on the course Moodle page by the due date.

Uploaded by

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

CS19003:

Programming and
Data Structure Lab
Lab 6: Structures, 2D arrays

Sandip Chakraborty
Submission Requirements
 On top of your code, enter your name and roll numbers within
comments.
/***********************************
* Name: Your Name
* Roll: Your Roll
**********************************/
Programming Practices
 Do not copy the code from others. Any form of plagiarism will lead
to zero marks.
 Take help of the Internet to solve the problem.
 If you get a compilation error, try to read the error message and find
out the reason behind the error.
 If you do not get the expected output, try to debug your code with
extra printf statements.
Zero Tolerance to Plagiarism
 You are supposed to write the entire code yourself
 Do not copy the code / a block of code from any other sources (Internet, or
from your friends)
 We'll take a zero-tolerance policy against plagiarism – if a significant
portion of the code is similar between two students, both will be given
zero.
 We'll not entertain any alibi like "both of us have copied from the same
Internet source", "I had shared my Moodle password to my fried", etc.
Submission Instructions
 Once you are done with a code, save the code in your local machine
as A6.c.

 Upload A6.c in Moodle course page, corresponding to Assignment 6


-- https://moodlecse.iitkgp.ac.in/
Problem
 Define a C structure called Points. The structure has two floating
point variables – x and y, to denote the x-coordinate and y-coordinate
of the point in a 2D Euclidean space.

 Now assume that you have a set of 16 points in a 2D Euclidean


space. These points are represented in a 4x4 matrix.
Problem - Cont.
 Write a C program to find out the number of equilateral triangles that can be
formed using those 16 points.
 Specifically, you need to write the following three functions:
 GetInput (Point mat[][]) -- to populate the 2D matrix of 16 points
 Dist (Point a, Point b) -- distance between two points
 IsEquiTriangle(Point a, Point b, Point c) -- to check whether an equilateral
triangle be formed with the three points. Use the Dist(...) function to implement this
function.
 CountEquiTriangle(…) -- a recursive function to calculate the number of equilateral
triangles. Use the IsEquiTriangle(…) function to implement this function.
Problem – Cont.
 You can use additional arguments in the functions and define the
return type of the functions as appropriate.
 You should not use any global variable in your code. However, you
can use static variables if necessary.
 You should not use pointer variables in your code.
 You can use math.h library if needed
Marks Distribution
 GetInput (...) -- 3 Marks
 Dist (...) -- 4 Marks
 IsEquiTriangle (...) -- 5 Marks
 CountEquiTriangle (...) -- 6 Marks (Give 3 Marks if the function is
non-recursive)
 main() -- 2 Marks

You might also like