Professional Documents
Culture Documents
Assignment 2
Assignment 2
Write your name, roll number, PC number and assignment number in the
header of the program file as comments. You may give your program file name
as <asgn><no_><RollNo>.c. For example, a student with roll number
21CS1001 should name the program file for assignment number 2(a), as
asgn2a_21CS1001.c.
Submit all the programs separately against each assignment (i.e. asgn2a,
asgn2b, and asgn2c) in the Moodle System.
All the results for each assignment should be submitted together in a separate
file (named result.txt). Provide the result in a separate output file (named,
result_<assgn><no>.txt). Use standard output redirection feature to generate
the output file.
Hints. Suppose you would like to redirect your output to a file ‘result.txt’.
If you run the program with the following command
./a.out >result.txt
If you execute the program multiple times, you may concatenate the
outputs in a single file by using the following redirection command:
./a.out >>result.txt
You may also store your input (the ordering as per requirement of
the program should be preserved) in an input file in.txt, and execute the
program as follows:
f(x)= x4-36x3+4x-3
2(b) Write a C-program which takes three distinct points (in 2-D
coordinates) as inputs and checks whether they form a triangle or
straight line. If they form a triangle, it prints “Formed triangle” and
prints its area. If they form a straight line, it prints “Formed Straight
Line” and prints the length between two end points. If any pair of
points are non-distinct, it prints coordinates of that point, and notifies
“Non-distinct input point” and prints the length between two distinct
points, if any.