Created
June 18, 2022 17:16
-
-
Save Welding-Torch/4779bcda4067fea702bdd8925f4412ab to your computer and use it in GitHub Desktop.
Assignment list for CP-Practical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
18 June, 2022 | |
Write a program to find the area of a triangle using Heron's Formula. | |
3 sides of a triangle | |
Herons formula is s=(a + b + c)/2 and then sqrt(s*(s-a)*(s-b)*(s-c)) | |
*******************************************************************************/ | |
#include <stdio.h> | |
#include <conio.h> | |
#include <math.h> | |
void main() | |
{ | |
int a, b, c, s; | |
float area; | |
printf("Enter the values of a, b, and c: "); | |
scanf("%d%d%d", &a, &b, &c); | |
s = a + b + c; | |
area = sqrt(s*(s-a)*(s-b)*(s-c)); | |
printf("\n The Area of the triangle is %d", area); | |
getch(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
18 June, 2022 | |
Write a program to find the biggest of three numbers. | |
*******************************************************************************/ | |
#include <stdio.h> | |
#include <conio.h> | |
void main() | |
{ | |
int a, b, c; | |
printf("\nEnter three numbers: "); | |
scanf("%d%d%d", &a, &b, &c); | |
if (a>b) | |
if (a>c) | |
printf("\nBiggest number is %d", a); | |
else | |
printf("\nBiggest number is %d", c); | |
else if (b>c) | |
printf ("\nBiggest number is %d", b); | |
else | |
printf("\nBiggest Number is %d", c); | |
getch(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
18 June, 2022 | |
Write a program to display the numbers from 1 to 100 that are divisible by 4 and 6. | |
*******************************************************************************/ | |
#include <stdio.h> | |
#include <conio.h> | |
void main() | |
{ | |
int i; | |
for (i=0;i<=100;i++) | |
{ | |
if (i%4==0 && i%6==0) | |
{ | |
printf("\nDivisible by 4 and 6: %d", i); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment