0% found this document useful (0 votes)
88 views13 pages

Programming For Problem Solving Lab (C) (ESCS - 291) Cse - 2 Sem. - 1 Year

The document is a student's programming assignment submission. It includes 5 programs written in C language to solve various problems: 1) Swapping two numbers using three variables and two variables. 2) Creating a simple calculator. 3) Calculating total salary based on basic pay, DA%, and HRA%. 4) Calculating area of a circle. 5) Converting temperature from Fahrenheit to Celsius. For each program, it includes the code, input/output, and description of the problem being solved.

Uploaded by

Md Imrajul Alam
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)
88 views13 pages

Programming For Problem Solving Lab (C) (ESCS - 291) Cse - 2 Sem. - 1 Year

The document is a student's programming assignment submission. It includes 5 programs written in C language to solve various problems: 1) Swapping two numbers using three variables and two variables. 2) Creating a simple calculator. 3) Calculating total salary based on basic pay, DA%, and HRA%. 4) Calculating area of a circle. 5) Converting temperature from Fahrenheit to Celsius. For each program, it includes the code, input/output, and description of the problem being solved.

Uploaded by

Md Imrajul Alam
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/ 13

Programming for Problem Solving Lab (C)

(ESCS - 291)
CSE – 2nd Sem. – 1st Year

Programming for Problem Solving Lab (C) – ES(CS)291


REPORT ON: …………………………..………………………………………………………………Lab.

MD IMRAJUL ALAM
NAME: …………………………………………………………………………………………………………..

COMPUTER SCIENCE & ENGINEERING


DEPARTMENT: ……………………………………………………………………………………………..

2ND
20/CSE/002 SEM: …….…….…
ROLL NO: .……………..….…… C
GRP: ….…… CSE-II
SECTION: ……..........

I
ASSIGNMENT NO: ………..……PROGRAM NO: …..………………………………………....
1,2,3,4,5

TITLE / OBJECTIVE:

1. SWAPING OF TWO NUMBERS (3 VARIABLES & 2 VARIABLES)


.………………………………………………………………………………………..................................

2. MAKING A SIMPLE CALCULATOR


……….………………………………………………………………………………..................................
3. CALCULATING THE TOTAL PAY OF A WORKER
………….……………………………………………………………………………..................................
4. FINDING THE AREA OF A CIRCLE
………….……………………………………………………………………………..................................
5. CONVERTING TEMPERATURE FROM FARENHEIT TO CELCIUS SCALE
………….……………………………………………………………………………..................................

18/05/2021 SUBMISSION DATE: ………………….......


PERFORMANCE DATE: …....……………….. 23/05/2021

EXAMINER’S SIGNATURE: ……………………………………………………………………………..


Assignment No. – I Page - 1 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

1. Write a C program to Swap the value of two Variables.(Using a 3 rd Variable &amp; without
Using a 3 rd Variable).

Program: PRG01(A).c

(i)// swapping 2 numbers using 3 variables

#include<stdio.h>

int main()
{

int a,b,temp;

printf("\t***********SWAPPING NUMBER**********\n\n");

printf("Enter the 1st number: ");


scanf("%d",&a);

printf("Enter the 2nd number: ");


scanf("%d",&b);

printf("Before swapping: a = %d & b = %d",a,b);

//swapping process
temp=a;
a=b;
b=temp;

printf("\nAfter swapping: a = %d & b = %d",a,b);

Assignment No. – I Page - 2 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

***********SWAPPING NUMBER**********

Enter the 1st number: 23

Enter the 2nd number: 46

Before swapping: a = 23 & b = 46

After swapping: a = 46 & b = 23

Process returned 0 (0x0) execution time : 5.968 s


Press any key to continue.

Assignment No. – I Page - 3 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

Program: PRG01(B).c

(ii)// swapping using 2 variables

#include<stdio.h>

int main()
{

int c,d;

printf("\t**************SWAPPING NUMBERS**************\n\n");

printf("Enter the 1st number: ");


scanf("%d",&c);

printf("Enter the 2nd number: ");


scanf("%d",&d);

printf("Before swapping: c = %d & d = %d",c,d);

//swapping process
c=c+d;
d=c-d;
c=c-d;

printf("\nAfter swapping: c = %d & d = %d", c,d);

Assignment No. – I Page - 4 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

**************SWAPPING NUMBERS**************

Enter the 1st number: 28

Enter the 2nd number: 56

Before swapping: c = 28 & d = 56

After swapping: c = 56 & d = 28

Process returned 0 (0x0) execution time : 12.162 s


Press any key to continue.

Assignment No. – I Page - 5 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

2.Write a Program in C to Make a Simple Calculator (Taking two Inputs & calculate their
Addition, Subtraction. Multiplication, Division).

Program: PRG02.c

//(Taking two Inputs & calculate their Addition, Subtraction. Multiplication, Division)

#include<stdio.h>

int main()
{
int a,b, SUM=0;

printf("\t-----# SIMPLE CALCULATOR #----- ");

printf("\nEnter the first number: ");


scanf("%d", &a);

printf("Enter the second number: ");


scanf("%d", &b);

SUM= a+b;

float div =(float)a/b;

printf("\nThe addition/summation of %d & %d is = %d.", a,b,SUM);

printf("\nThe subtraction of %d & %d is = %d.", a, b, a-b);

printf("\nThe multiplication of %d & %d is = %d.", a, b, a*b);

printf("\nThe division of %d & %d is = %f.", a, b, div);

printf("\nThe remainder of %d & %d is = %d.", a, b, a%b);

Assignment No. – I Page - 6 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

-----# SIMPLE CALCULATOR #-----

Enter the first number: 10

Enter the second number: 3

The addition/summation of 10 & 3 is = 13.

The subtraction of 10 & 3 is = 7.

The multiplication of 10 & 3 is = 30.

The division of 10 & 3 is = 3.333333.

The remainder of 10 & 3 is = 1.

Process returned 0 (0x0) execution time : 3.352 s


Press any key to continue.

Assignment No. – I Page - 7 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

3. Write a Program in C to Make a Salary Calculator. Taking three Inputs: Basic, DA(%) &
HRA(%) calculate the Total Pay where Total Pay=Basic + (Basic x DA %) + (Basic x HRA %).

Program: PRG03.c

#include<stdio.h>

int main()
{

float basic,HRA,DA,Total_Pay;

printf("\t**********SALARY CALCULATOR**********\n\n");

printf("Enter the basic pay: ");


scanf("%f",&basic);

printf("Enter the dearness allowance: ");


scanf("%f",&DA);

printf("Enter the house rent allowance: ");


scanf("%f",&HRA);

Total_Pay=basic+(basic*DA/100)+(basic*HRA/100);

printf("The total pay is: %0.2f",Total_Pay);

Assignment No. – I Page - 8 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

**********SALARY CALCULATOR**********

Enter the basic pay: 20000

Enter the dearness allowance: 80

Enter the house rent allowance: 100

The total pay is: 56000.00

Process returned 0 (0x0) execution time : 5.587 s


Press any key to continue.

Assignment No. – I Page - 9 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

4. Write a C program to find out the Area of a Circle.

Program: PRG04.c

// calculating the area of a circle

#include<stdio.h>
#include<math.h>

int main()
{

float radius,area;

printf("\t**********AREA CALCULATOR**********\n\n");

printf("Enter the radius of the circle: ");


scanf("%f",&radius);

//calculating area
area=(3.14)*pow(radius,2);

printf("The area of the circle of radius %0.2f: %0.2f",radius,area);

Assignment No. – I Page - 10 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

**********AREA CALCULATOR**********

Enter the radius of the circle: 12.3

The area of the circle of radius 12.30: 475.05

Process returned 0 (0x0) execution time : 2.417 s


Press any key to continue.

Assignment No. – I Page - 11 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

5. Write a C program to convert temperature from Fahrenheit to Celsius.

Program: PRG05.c

// temperature conversion from Fahrenheit to Celsius

#include<stdio.h>

int main()
{

float Fahrenheit, Celsius;


printf("\t**********TEMPERATURE CONVERSION**********\n\n");

printf("Enter the temperature in Fahrenheit scale: ");


scanf("%f",&Fahrenheit);

Celsius=(Fahrenheit - 32)*5/9;

printf("The equivalent temperature in Celsius scale is: %0.3f",Celsius);

Assignment No. – I Page - 12 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM
Programming for Problem Solving Lab (C)
(ESCS - 291)
CSE – 2nd Sem. – 1st Year

OUTPUT:

**********TEMPERATURE CONVERSION**********

Enter the temperature in Fahrenheit scale: 120

The equivalent temperature in Celsius scale is: 48.889

Process returned 0 (0x0) execution time : 2.236 s


Press any key to continue.

Assignment No. – I Page - 13 MD IMRAJUL ALAM, 20/CSE/002, </> CSE Dept, FIEM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy