Aim:Write a program to demonstrate simple computational problems using arithmetic expressions
The previous program gives the basic understandably of C Programming environment, and this program implements the arithmetic logic’s of finding area, circumference and volume of different shapes such as circle, rectangle, square and cube.
Source Code:
#include<stdio.h>int main(){ int length, width, radius, height; float area, circumference,pi,volume; pi=3.14; printf("******************Rectangle********************* \n"); printf("Enter the Length of Rectangle = "); scanf("%d",&length); printf("Enter the Width of Rectangle = "); scanf("%d",&width); area=length*width; circumference=2*(length+width); printf("Area of Rectangle = %f\n",area); printf("Circumference of Rectangle = %f\n",circumference); printf("************************************************ \n"); printf("******************Circle********************* \n"); printf("Enter the Radius of Circle = "); scanf("%d",&radius); area=pi*radius*radius; circumference=2*pi*radius; printf("Area of Circle = %f\n",area); printf("Circumference of Circle = %f\n",circumference); printf("************************************************ \n"); printf("******************Square********************* \n"); printf("Enter the any side of Square = "); scanf("%d",&length); area=length*length; circumference=4*length; printf("Area of Square = %f\n",area); printf("Circumference of Square = %f\n",circumference); printf("************************************************ \n"); printf("******************Cube********************* \n"); printf("Enter the Length of Cube = "); scanf("%d",&length); printf("Enter the Width of Cube = "); scanf("%d",&width); printf("Enter the Height of Cube = "); scanf("%d",&height); volume=length*width*height; printf("Volume of Cube = %f\n",volume); printf("************************************************ \n"); return 0;}
Output:
Note: The whole code is done in CodeBlocks. You can download CodeBlocks software from this link:http://www.codeblocks.org/downloads/26
Comments