Tags » C Program

C Program to Calculate the area of a triangle

/* Calculate the area of a triangle */

#include
#include

int main() {

    float a, b, c;
    float s, area;

    printf("Enter size of each sides of triangle: ");
    scanf("%f%f%f", &a, &b, &c);

    s = (a+b+c) / 2;
    area = sqrt(s* (s-a) * (s-b) * (s-c));

    printf("Area of triangle is: %.3f", area);

    getch();
    return 0;
}
C Programs

C Program to calculate the area of a rectangle

/* Program to calculate the area of a rectangle */
#include <stdio.h>

int main() {

float l, w;
float area;

printf("Enter size of each sides of the rectangle: ");
scanf("%f%f", &l, &w);

area = l * w;
printf("Area of rectangle is: %.3f", area);

getch();
return 0;
}
C

C program to calculate area of circle

/* Calculate the area of a circle */

#include <stdio.h>
#define PI 3.141

int main() {
float r, a;

printf("Enter radius of the circle: ");
scanf("%f", &r);
a = PI * r * r;
printf("Area is %f\n", a);

getch();
return 0;
}
C Programs

Swapping of two numbers in a single line

#include”stdio.h”                           // # is preprocessor directive.,include is used to insert the library,stdio is standard input output,and .h is used to insert the header file like stdio and any other.. 133 more words

Caesar Cipher

Caesar Cipher is one of the earliest publicly know cipher. The method is named after Julius Caesar, who used it in his private correspondence. It is a type of substitution cipher in which each letter of plain text  is shifted to fixed number of positions down the alphabet.   524 more words

Cryptography

Binary Tree construction using inorder and postorder traversal

#include<stdio.h>
#include<stdlib.h>
struct node
{
char data;
struct node* left;
struct node* right;
};

int search(char arr[], int strt, int end, char value);
struct node* newNode(char data); 198 more words

Algorithm

HELLO WORLD IN C++

In C++ too first we have to add HEADER FILES.

Header files contain certain functions and keywords. Here we add a header file called… 80 more words

C