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

OPEN ENDED LAB

Subject:
Fundamental Programing
Submitted To:

Engr: Sikandar Seleem

Submitted By:

-------------

Roll Number:

2023-EE-(---)

Section:

2023 – 2027

Department:

B.Sc. Electrical Engineering


Open ended lab
Write a program that input a number in main function and passes the
number to a function. The function display table of that number.
Objective:
 Write a program that the function display table of that number.
Code:
#include <stdio.h>

// Function to display the multiplication table of a given number


void displayTable(int number) {
printf("Multiplication Table for %d:\n", number);
for (int i = 1; i <= 10; ++i) {
printf("%d x %d = %d\n", number, i, number * i);
}
}

int main() {
int userInput;

// Input a number from the user


printf("Enter a number: ");
scanf("%d", &userInput);
// Display the multiplication table for the entered number
displayTable(userInput);

return 0;
}
Flow Chart:

Start

Declear num

Read num

Call table(num)

End
Output:
Enter a number: 8
Multiplication table for 8:
8*1=8
8*2=16
8*3=24
8*4=32
8*5=40
8*6=48
8*7=56
8*8=64
8*9=72
8*10=80
Conclusion:
In this lab we have learnt how to write a program that the function displays table of that number.

You might also like