0% found this document useful (0 votes)
15 views8 pages

CSE 104.1v

Uploaded by

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

CSE 104.1v

Uploaded by

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

Computer Programming Lab Report - 01

Course Title: Computer Programming Laboratory


Date of Experiment : Date-09/11/2024

Submitted by : Nusrat Jahan,


ID : 233004910
Section :1
Instructor : Md. Jamil Uddin
Implementation of basic C programs

Objectives

Objectives of the experiment.


To solve this
 Ramesh’s basic salary is input through the keyboard. His dearness
allowance is 40% of basic salary, and house rent allowance is 20% of basic
salary. Write a program to calculate his gross salary.
 Temperature of a city in Fahrenheit degrees is input through the keyboard.
Write a program to convert this temperature into Celcius degrees.
 The length and breadth of a rectangle and radius of a circle are input
through the keyboard. Write a program to calculate the area and perimeter
of the rectangle, and the area and circumference of the circle.

Required Equipment/Software

List all hardware and software needed for the lab:


 Operating System: Windows
 Programming Language: C Programming (GCC compiler)
 IDE: CodeBlocks
Theory

In this experiment, basic C programming concepts are used to perform


calculations. The functions printf() and scanf() are used for input/output
operations.
 printf(): A function that is used to output text or variable values to the
console. It can handle various format specifiers to display different types of
data, such as integers, floats, and strings.
 scanf(): A function used to read user input. It allows the program to accept
values from the user and store them in variables.
 Variables: In C, variables are used to store data. The type of variable (int,
float) is defined during declaration.

Program Code
1)
#include <stdio.h>
int main()
{
float bs, da, hr,gs;
printf("basic salary=");
scanf("%f",&bs);
da=0.4*bs;
hr=0.2*bs;
bs=bs+da+hr;
printf("Dearness allowance=%.1f\nHouse rent allowance=%.1f\nGross
salary=%.1f ",da,hr,bs);
return 0;
}

2)
#include<stdio.h>
int main()
{
float fahrenheit,celsius;
printf("enter temperature in fahrenheit=");
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32)*5/9;
printf("Fahrenheit to Celsius=%f",celsius);
return 0;
}
3)
#include<stdio.h>
#include<math.h>
int main()
{
int length,breadth,radius;
printf("Enter the length of the rectangle= ");
scanf("%d",&length);
printf("Enter the breadth of the rectangle= ");
scanf("%d",&breadth);
printf("Enter the radius of the circle= ");
scanf("%d",&radius);
float area_r,perimeter,area_c,circumference;
area_r=length*breadth;
perimeter=2*(length+breadth);
area_c=3.1416*pow(radius,2);
circumference=2*3.1416*radius;
printf("Rectangle Area: %.1f\n",area_r);
printf("Rectangle Perimeter: %.1f\n",perimeter);
printf("Circle Area: %.1f\n",area_c);
printf("Circle Circumference: %.1f",circumference);
return 0;
}

Input and Output

1)
2)
3)

Conclusion

In this lab, we implemented three C programs that accomplished different tasks,


such as calculating gross salary, converting temperatures, and computing
geometric properties. Through this, we applied fundamental C concepts including
input/output functions scanf() and printf(), arithmetic operations, and variable
declarations. The objectives were successfully achieved, and the programs ran as
expected.

You might also like