0% found this document useful (0 votes)
28 views11 pages

Asynchronous Activity-21st Sept. 2020: Program 1

The document contains 3 C programs that calculate: 1) The type of triangle based on side lengths 2) Whether a year is a leap year 3) The area of different shapes like circle, rectangle, square, triangle based on user input

Uploaded by

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

Asynchronous Activity-21st Sept. 2020: Program 1

The document contains 3 C programs that calculate: 1) The type of triangle based on side lengths 2) Whether a year is a leap year 3) The area of different shapes like circle, rectangle, square, triangle based on user input

Uploaded by

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

Asynchronous Activity- 21st Sept.

2020

Program 1
#include <stdio.h>

int main()
{
int a,b,c;
printf("Dunchu Tenzin Tsewang 2060339\n");
printf("Enter three sides of triangle:\n");
scanf("%d%d%d",&a,&b,&c);

if(a>=(b+c))
printf("No triangle\n");
else if((a*a)==((b*b)+(c*c)))
printf("Right angled triangle\n");
else if((a*a)>((b*b)+(c*c)))
printf("Obtuse angled triangle\n");
else if((a*a)<((b*b)+(c*c)))
printf("Acute angled triangle\n");
else
printf("Triangle not valid!!!");

return 0;

Output
Algorithm-1
Flowchart-1
Program-2
#include <stdio.h>

int main()
{
int year;
printf("Dunchu Tenzin Tsewang 2060339\n");
printf("Enter Year:\n");
scanf("%d",&year);

if(year%4==0)
{
if(year%100!=0)
printf("Leap year!\n");
}
else if(year%400==0)
printf("Leap year!\n");
else
printf("Not leap year!\n");
return 0;
}

Output
Algorithm-2
Flowchart-2
Program-3
#include <stdio.h>
int main()
{
int ch;
float area,side,length,breadth,base,height,radius;
printf("Dunchu Tenzin Tsewang 2060339\n");
printf("Areas of different shapes:\n");
printf("1. Circle\n");
printf("2. Rectangle\n");
printf("3. Square\n");
printf("4. Triangle\n");

printf("Enter your choice(1-4):\n");


scanf("%d",&ch);

switch(ch)
{
case 1:
{
printf("Enter radius:\n");
scanf("%f",&radius);
area=3.14*radius*radius;
printf("Area is %f\n",area);
break;
}
case 2:
{
printf("Enter Length:\n");
scanf("%f",&length);
printf("Enter breadth:\n");
scanf("%f",&breadth);
area=length*breadth;
printf("Area is %f\n",area);
break;
}
case 3:
{
printf("Enter side:\n");
scanf("%f",&side);
area=side*side;
printf("Area is %f\n",area);
break;
}
case 4:
{
printf("Enter base:\n");
scanf("%f",&base);
printf("Enter height:\n");
scanf("%f",&height);
area=0.5*base*height;
printf("Area is %f\n",area);
break;
}
default:
printf("Invalid!!!\n");
}
return 0;

Output

Algorithm-3
Flowchart-3

You might also like