0% found this document useful (0 votes)
14 views2 pages

01 LabManual ENG3202 2023-2024 Lab1

Uploaded by

rocksports847
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)
14 views2 pages

01 LabManual ENG3202 2023-2024 Lab1

Uploaded by

rocksports847
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/ 2

ENG3202 Computer Programming 2022-2023

LAB 1: INTRODUCTION TO C PROGRAMMING

Objective To introduce C language.


To edit, create, compile, execute and debug a simple text output program written
in C language.

Equipment Personal Computer with C Program IDE Pre-Installed

General guideline for all lab exercises and reports:


a. Generate a pseudocode for the program.
b. Generate a flow chart for the program (Only if flowchart has already been covered
in lecture)
c. Provide relevant comments on the codes
d. In the case of compiling given program, run the program and record any errors
encountered.
e. Debug the error, compile and run the program. Record the program output.
f. If you are required to design a program, design working codes, debug and run as
well as show the output.
g. Provide discussion and analysis of your results.
h. You may copy the program and results images or screenshot from the IDE and
paste it into your report

Procedure
2. Locate and execute C programming IDE in your computer.

3. Enter listing 1.1 into the editor. Compile, run and debug the codes if necessary.

Listing 1.1
/* This program is to convert the temperature in Celsius to its corresponding
Fahrenheit value. Happy trying! */

#include stdio.h

int main
{
/* local declarations */
float Celsius,
int fahrenheit;

/* prompt the user to key in the temperature in Fahrenheit */


printf(“Enter temperature in Celcius: “);

/* the value is passed into the variable named Fahrenheit */


scanf(“%f”, &celcius);

/* computation of the conversion */


fahrenheit = ((9.0 / 5.0) * celcius) + 32;

/* displaying the corresponding Celsius value */


printf(“the value in Fahrenheit is: %f”, fahrenhiet);

return 0;
}
4. Redo step 2 using listing 1.2, 1.3 and 1.4.

1
Listing 1.2
/* this is an example program
*
#include <stdio.h>
main
() {int num; printf (“This is”);
printf (“a program”
); printf
(
“that does not”
);printf(
“look too good.”
);
Printf
(“Enter a number >”);scanf(
“%d”,&num);printf
(“This is number%d”,
num);return
0;}

Listing 1.3
/* this program has error(s)
#include <stdio.h>

int main (void)


{
printf “hello THERE !!”);
printf(‘we are to find’];
printf (‘the error’);
return 0
}

Listing 1.4
/this is another program with some errors in it and needs to be corrected/

#include (stdio.h)

void main (void)


{
/*local variable declarations

a = 3 int;
b = 5.3 float, double;
c,d = a,b character;

/*statements
printf (The values are: , a,b,c,d);
printf(“the end of the program’)

return 0;
}/*main*/

-End-

You might also like