Chapter - 16: Miscellaneous Features

Write a function that receive variable number of arguments, where the argument are the coordinates of a point. Based on the number of arguments received, the funtion should display the type of shape like a point, line, triangle etc. that can be drawn.


C
Sections
2
Exercises

A

B

C

1

2

3

4

#include<stdio.h>
#include<conio.h>
#include<stdarg.h>

void type(int, ...);

int main()
{
	type(5, 4, 6, 3, 6, 7);
	return 0;
}

void type(int point, ...)
{
	if (point < 1)
	{
		printf("Nothing can be draw.");
		return;
	}
	switch (point)
	{
	case 1:
		printf("A point can be drawn.\n");
		break;
	case 2:
		printf("A line can be drawn.\n");
		break;
	case 3:
		printf("A triangle can be drawn.\n");
		break;
	case 4:
		printf("A rectangle can be drwan.\n");
		break;
	case 5:
		printf("A pentagon can be drawn.\n");
		break;
	case 6:
		printf("A hexagon can be drawn.\n");
		break;
	default:
		printf("A polygon can be drawn.\n");
	}
}

© 2020 Garbage Valuegarbage value logo