Computer Programming (ELC-121L) Lab Manual
LAB#01
Task 1:
Coding:
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int V,I,R;
printf("Enter the value of I: ");
scanf("%d", &I);
printf("Enter the value of R: ");
scanf("%d", &R);
V = I * R;
printf("Voltage (V) = %d volts\n" ,V);
getch();
}
Output:
Enter the value of I: 10
Enter the value of R: 20
Voltage (V) = 200 volts
Task 2:
Coding:
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
float A,r;
printf("Enter the value of radius: ");
scanf("%f", &r);
A=3.142*r*r;
printf("Area (A) = %f\n" ,A);
getch();
}
Output:
Enter the value of radius: 1
Area (A) = 3.142000
Electrical Engineering Technology Department
Sir Syed University of Engineering & Technology.
Computer Programming (ELC-121L) Lab Manual
Task 3:
Coding:
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
float A,b,h;
printf("Enter the value of breath: ");
scanf("%f", &b);
printf("Enter the value of height: ");
scanf("%f", &h);
A = 1.0/2.0*b*h;
printf("Area (A) = %f\n" ,A);
getch();
}
Output:
Enter the value of breath: 2
Enter the value of height: 4
Area (A) = 4.000000
Task 4:
Coding:
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
float F,C;
printf("Enter the value of Centigrade: ");
scanf("%f", &C);
F=C*9.0/5.0+32.0;
printf("Fahrenheit (F) = %f\n" ,F);
getch();
}
Output:
Enter the value of Centigrade: 40
Fahrenheit (F) = 104.000000
Electrical Engineering Technology Department
Sir Syed University of Engineering & Technology.
Computer Programming (ELC-121L) Lab Manual
Conclusion and Learning:
• Turbo C Environment: Explored the interface, tools, and navigation
methods within Turbo C, facilitating a comfortable environment for C++
programming.
• C++ Program Basics: Introduced the foundational structure of a C++
program, highlighting the importance of libraries, the main function, and
basic syntax for input and output operations (using 'cin' and 'cout').
• Input and Output Operations: Focused on the significance of 'cin' for
receiving user input and 'cout' for displaying output on the console,
showcasing their use within basic C++ programs.
• Compilation and Execution: Illustrated the process of compiling written
code into an executable file and executing the program within the Turbo
C environment.
• Troubleshooting and Debugging: Emphasized the identification and
resolution of common coding errors, utilizing Turbo C's debugging tools
to enhance problem-solving skills.
• Learning Outcomes: Aimed to provide a solid grasp of the Turbo C
environment, enabling participants to confidently create, execute, and
debug simple C++ programs.
Electrical Engineering Technology Department
Sir Syed University of Engineering & Technology.