Sei sulla pagina 1di 9

PDS Lab Section 13

August 8, 2019
Program Header

• Every program must start with a comment containing


• Section No.
• Machine no.
• Roll No.
• Name
• Assignment No.
• A one line description of the assignment
Example Header

/******************************
* Section 13
* M/c No : 65
* Roll No : 19CS30001
* Name : Foolan Barik
* Assignment No : 1
* Description : Program to find area of a circle
*******************************/
Naming your program
• There will be one C file for each assignment
• Name your C file 13_m_n.c where m is your machine no., and n is the
assignment no. For example,
• 13_12_3a.c if you are sitting in machine no. 12 and this file is for assignment no.
3a
• 13_6_4b.c if you are sitting in machine no. 6 and this file is for assignment no. 4
• Your filename must end with .c for it to work
Assignments
Assignment 1A

Write a C program which will compute the sum of first n


terms of an Arithmetic Progression series. The program will
first read the first term (a, type float), difference of two
terms (r, type float) and the value of n ( type integer). The
program will print the sum of first n terms of the series.
Assignment 1B

Write a program that will do the following:


• Read the length base B and height H of a triangle (using a
single scanf statement)
• Compute the area A and of the triangle
• Print the value of A with a suitable message (using a single
printf statement).

You can assume that B and H are integers.


Assignment 1C
A rectangle with sides parallel to the X and Y-axis can be fully
specified by specifying the (x,y) coordinates of the bottom-
left corner and the top-right corner as shown below:

(c,d)

(a,b)

Write a program that will do the following (in this order):


• Read the coordinates (a, b) of the bottom-left corner of the
rectangle (read both a and b in a single scanf statement)
• Read the coordinates (c, d) of the top-right corner of the
rectangle (read both c and d in a single scanf statement)
• Compute the area and perimeter of the rectangle. Store then in
variables A and P respectively.
• Print the values of A and P with a suitable message (using a single
printf statement)
• Compute the coordinates (p,q) of the point of intersection of the
two diagonals of the rectangle
• Print the coordinates (p,q) with a suitable message (using a single
printf statement)

Assume that all coordinates entered from the keyboard will be positive
integers. However, the actual coordinates can be real numbers (so the
computed coordinate can be a real number)

Potrebbero piacerti anche