Kamran Icp Lab Report
Kamran Icp Lab Report
Kamran Icp Lab Report
LAB REPORT 1
Objectives
• Learn to use IDE such as Code Blocks for compiling and debugging computer
programs
written in C language.
Software Used
• MinGW C Compiler
Pre Lab
Get the Code Block IDE and MinGW C Compiler setup files from the lab and install
them on your computer.
In-Lab
int main()
scanf("%d", &num1);
scanf("%d", &num2);
return 0;
#include <stdio.h>
#include <stdlib.h>
int main()
printf("Enter a number for which you want to find the factorial: \n");
R = N; // let R = N
do
while(x>=1); // repeat above steps from multiplication till x is greater than or equal to 1
return 0;
2 − 5𝑛, 𝑛 ≤ −10
3 − 50𝑛, 𝑛 ≥ −2
𝑛 𝑖𝑠 𝑎𝑛 𝑖𝑛𝑡𝑒𝑔𝑒𝑟
Fill the table using the above equation for values of n 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]
-20 500 0 0
-13 234 7 -7
-9 10 11 781
-8 11 12 1128
-7 12 13 1547
-6 13 14 2044
-5 14 15 2625
-4 15 16 3296
-3 16 17 4063
-2 92 18 4932
-1 49 19 5909
20 7000
#include <stdio.h>
#include <stdlib.h>
int main(void)
int n;
int output;
if(n<=-10)
else if((n>-10)&&(n<-2))
{ output = n+19;
else if(n>=-2)
}
printf("%d ", 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.
#include <stdio.h>
#include <stdlib.h>
int main()
int n;
int output;
if(n<3)
{ output =-(n+4);
} else if((n>=3)&&(n<=10))
{ output =n*n-7;
} else if(n>10)
{ output = (120/n)+(n);
} printf("\n\n");
return 0;
Critical Analysis:
First lab demonstrate us about the basics of C Programming,
which includes analysis and running codes on Code Block, we
have learned how to write a simple program on code block,
secondly this lab has improved my knowledge to deal with errors
during compiling a program. We studied about breakpoint and
debugger, which is responsible to identify and fix errors in our
codes. We practiced setting breakpoints, stepping through code,
and inspecting variables in the debugger.