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

Comp Prog Lab 9

The document is a lab manual for Computer Programming (ELC-121L) that includes two tasks: coding a biodata collection program and a simple calculator program. It emphasizes key programming concepts such as function fundamentals, prototypes, header files, and modular programming. The conclusion highlights the practical application of these concepts in organizing and modularizing code.

Uploaded by

Alishan 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)
85 views2 pages

Comp Prog Lab 9

The document is a lab manual for Computer Programming (ELC-121L) that includes two tasks: coding a biodata collection program and a simple calculator program. It emphasizes key programming concepts such as function fundamentals, prototypes, header files, and modular programming. The conclusion highlights the practical application of these concepts in organizing and modularizing code.

Uploaded by

Alishan 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

Computer Programming (ELC-121L) Lab Manual

Lab#09
Task 1:
Coding:
#include<stdio.h>
#include<biodata.h>
#include<conio.h>

void main(void)
{

printf ("Please provide your biodata:\n");


displayBiodata ();
getch ();
}

Output:
Please provide your biodata:
Enter your name: Ali
Enter your age: 25
Enter your gender: Male
Enter your address: 123 Street, Karachi
Enter your contact number: 1234567890

My Biodata:
Name: Ali
Age: 25
Gender: Male
Address: 123 Street, Karachi
Contact: 1234567890

Task 2:

Coding:
#include<stdio.h>
#include<calculator.h>
#include<iostream>

void main(void)
{
clrscr ();
Calculator calc;
float num1, num2;
char a;
printf ("Enter first number: ");
scanf ("%f", &num1);
printf ("Enter operator (+, -, *, /): ");

Electrical Engineering Technology Department


Sir Syed University of Engineering & Technology.
Computer Programming (ELC-121L) Lab Manual

scanf (" %c", &a);


printf ("Enter second number: ");
scanf ("%f", &num2);
float result;
switch (a) {
case '+':
result = [Link] (num1, num2);
break;
case '-':
result = calc. subtract (num1, num2);
break;
case '*':
result = calc. multiply (num1, num2);
break;
case '/':
result = calc. divide (num1, num2);
break;
default:
printf ("Invalid operator!");
return 1;
}
printf ("Result: %f\n", result);
getch ();
}

Output:
Enter first number: 10
Enter operator (+, -, *, /): *
Enter second number: 5
Result: 50.000000

Conclusion and Learning:


In a lab focused on explaining functions and header files, the conclusion and learning
outcomes might include:
• Function Fundamentals: Covered function declaration, definition, parameters, return
types, and function calls as modular blocks of code performing specific tasks.
• Function Prototypes: Explored the concept of function prototypes, emphasizing their
role in header files to declare functions before implementation.
• Header Files: Introduced the purpose and usage of header files containing function
prototypes, constants, and declarations for multiple source files.
• Modular Programming: Emphasized the benefits of modular programming using
functions and header files for code reusability, readability, and easier maintenance.
• Practical Application: Engaged in exercises demonstrating the utilization of
functions and header files for organizing and modularizing code in real-world
scenarios.

Electrical Engineering Technology Department


Sir Syed University of Engineering & Technology.

You might also like