Lab Report 01: Name: Ahmed Khan ID: 2023-3-60-576 Course: CSE103 Section: 07

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

‭Lab Report 01‬

‭ ubmitted by:‬
S
‭Name: Ahmed khan‬
‭ID: 2023-3-60-576‬
‭Course: CSE103‬
‭section: 07‬

‭ ubmitted To:‬
S
‭Mohammad Arifuzzaman Ph.D.‬
‭Associate Professor‬
‭ epartment of Computer Science and Engineering‬
D

‭Submission date:‬
‭05-10-2023‬
‭Introduction:‬

I‭ n today lab1 we are learning about the “printf and scanf functions” of the C programming‬
‭language. Also, we use different kinds of functions like printf and scanf to write some C‬
‭programming.‬

‭ roblem 1:‬‭Calculate area of a circle.‬


P
‭Problem Analysis:‬‭In this problem we need to find out the area of the circle using printf and‬
‭scanf function.‬

‭Code:‬

#‭ include<stdio.h>‬
‭int main(){‬
‭float area,r;‬
‭printf("Enter the value of radius\n");‬
‭scanf("%f", & r);‬
‭area = 3.1416*r*r;‬
‭printf("The value of area is %f", area);‬
‭return 0;‬
‭}‬

‭Output‬‭: I input 5 and it gives me the area of circule 78.540001.‬

‭Problem 2:‬ ‭Convert a temperature from Fahrenheit to Celsius.‬

‭ roblem Analysis:‬‭In this problem we need to convert fahrenheit to celsius using printf and‬
P
‭scanf function.‬
‭Code:‬
#‭ include<stdio.h>‬
‭int main(){‬
‭float f,c;‬
‭printf("Enter the value of Fahrenheit\n");‬
‭scanf("%f", & f);‬
‭c=((f-32)*5)/9;‬
‭printf("The value of Fahrenheit to Celsius is %f", c);‬
r‭ eturn 0;‬
‭}‬

‭Output‬‭: I input -40 and it gives me the fahrenheit to celsius -40.‬

‭ roblem 3:‬ ‭Convert a temperature from Celsius to Fahrenheit.‬


P
‭Problem Analysis:‬‭In this problem we need to convert celsius to farhrenheit using printf and‬
‭scanf function.‬

‭Code:‬
#‭ include<stdio.h>‬
‭int main(){‬
‭float f,c;‬
‭printf("Enter the value of Celsius\n");‬
‭scanf("%f", & c);‬
‭f=((9*c)/5)+32;‬
‭printf("The value of Celsius to Fahrenheit is %f", f);‬
‭return 0;‬
‭}‬

‭Output‬‭: I input -40 and it gives me the celsius to farhreneit -40.‬

‭Problem 4:‬‭Find the temperature T from the following equation: PV= nRT. Where, P, V, n, R‬
‭represents pressure, volume, amount of substance and ideal gas constant. R= 8.314 J/mol·K.‬

‭ roblem Analysis:‬‭In this problem we need to find the temperature using printf and scanf‬
P
‭function.‬
‭Code:‬

#‭ include<stdio.h>‬
‭int main()‬
‭{‬
‭float p,v,n,t;‬
‭printf("Enter the value of pressure\n");‬
‭scanf("%f", & p);‬
‭printf("Enter the value of volume\n");‬
‭scanf("%f", & v);‬
‭printf("Enter the value amount of substance\n");‬
‭scanf("%f", & n);‬
‭t=(p*v)/(8.314*n);‬
‭printf("The value of temperature is %f", t);‬
‭return 0;‬
‭}‬

‭Output‬‭: I input pressure is 5, volume is 5, amount of substance 5 and it give me output of‬

‭temperature is 0.601395.‬

‭ onclusion:‬
C
‭Today we are solving some problems using printf function and scanf function. All problems‬
‭we are solving use this function, printf shows me (“”) the output of this quotation, scanf it‬
‭gives some input from the user. Which helps to understand the concept of printf and scanf‬
‭function in C programming language.‬

You might also like