In Lab
In Lab
In Lab
Task No. 01
Make a new C project (console application) using CodeBlocks and type the following code in the
main.c file. Build and run the code and fix the indicated errors.
Program No. 01
#include <stdio.h>
#include <stdlib.h>
int main()
{
int N = 0; // Take a number N.
printf("Enter a number for which you want to find the factorial: \n");
Scanf("%d", &N); // Get input from the user
printf("\nYou entered: %d\n\n", n); // Display what the user entered.
{ 𝑛 𝑖𝑠 𝑎𝑛 𝑖𝑛𝑡𝑒𝑔𝑒𝑟
Task No. 02
Fill the table using Equation 01 for values of t from -20 to 20. You will be using this table to compare
the output of the program in the next task and fixing some logical errors.
n f[n] n f[n]
Task No. 03
Type and build the following code in a new CodeBlocks project. Compare the output of the program
with the table in task 1. Find any logical error and write the correct program.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int range_min = -20;
int range_max = 20;
int n;
int output;
}
printf("\n\n");
return 0;
}
Post Lab:
Modify the above C program for the following piecewise function and report the problems you face.
Use integer variables for your program.
−𝑛 − 4, 𝑛<3
𝑛2 − 7, 3 ≤ 𝑛 ≤ 10
120
𝑓[𝑛] = 𝑛
+ 𝑛, 𝑛 > 10