C-Lab ND1 Manual 2023 113335
C-Lab ND1 Manual 2023 113335
C-Lab ND1 Manual 2023 113335
Level: ND1
Semester: Second
Session: 2022/2023
Week One
It is a data processing machine which accepts data via an input device and its processor
1. System Programs
2. Application Program
1. System Program
Program that are needed to keep all the hardware and software systems running together smoothly
2. Application Program
Application is set program instructions that direct the computer to perform specific task Example:
Microsoft Excel, Microsoft Word, Microsoft Power Corel draw, Browser etc.
Compiler:
Compiler is a software which used to translate high-language (programming language) like Java,
C, C++, C# etc. Source codes into lower-level language (machine code/bytecode) for directing the
computer to do task.
Example as follows:
1
1. Java Compiler e.g Eclipse, Jgrasp, NetBeans etc
3. C#
Source Code
(Program)
C Language
Compiler Data
Output
Data Input
2
EXECUTING/RUNNING C LANGUAGE SOURCE CODE:
Then, go to Build > click on Build and Run to run (execute) the program
Week Two:
3
Program 1
Source Code:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
Output:
Hello World!
Program 2:
Write a C programming source code that print “Hello World! and I am learning C
Source Code:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
Output:
Program 3
#include <stdio.h>
int main() {
int myNum;
myNum = 15;
printf(“%d”,myNum):
return(0); }
Output:
15
Week Three:
Program 4
Write a program that will print three different data types include integer, float and character values
in c compiler.
#include <stdio.h>
Int main()
printf("%f\n", myFloatNum);
printf("%c\n", myLetter);
Return(0); }
Output:
5.99
5
D
Week Four:
Program 5
write a program that will declares more one variable on one line
Source Code:
#include <stdio.h>
int main () {
int x = 5, y = 6, z = 50;
printf("%d", x + y + z);
return(0);
Output:
61
Program 6
Source Code
#include <stdio.h>
int myNum = 5;
return(0);
Output:
Program 7
#include <stdio.h>
int myNum = 5;
return(0);
Output:
Exercise 2
Write c program that calculate the sum and the average of four student’s scores of English, Maths,
Week Five:
Program 8
Write a program that will compute the area and circumference of the circle.
Source Code:
#include <stdio.h>
int radius;
radius=5
area= pi*radius*radius;
7
circumference=2*pi*radius;
return (0);
Output:
Program 9
Write a program that calculate the area and circumference of the circle to input the radius of a
Source Code:
#include <stdio.h>
int radius;
scanf(“%d”,radius);
area= pi*radius*radius;
circumference=2*pi*radius;
return(0); }
Output:
Week Six:
Program 10
Write c program that perform arithmetic operation with different arithmetic operators
Source Code:
#include <stdio.h>
int main () {
return(0);
Output:
Program 11
Write a program that compute the exponential and modulus of num1 and num2 of 5 and 2 ,
Output:
Exercise 3
Write a source code that perform arithmetic operation of the following operators:
(i) Addition (+) (ii) Subtraction (-) (iii) Multiplication (x) (iv) Division
Week Seven:
Program 12
s1 = “Hello”;
s2 =”World!”;
Source Code:
#include <stdio.h>
int main(){
char s1=”Hello”;
char s2=”World!”;
printf(“%s”, s1+s2);
return(0);
}
10
Output
HelloWorld!
Program 13
Write a computer program using c language to print “Hello word!” with white space.
#include <stdio.h>
int main(){
printf("%s", greetings);
return(0);
Output:
Hello World!
Exercise:
i. Write a python source code that concatenate the following string ‘F,’ ‘C’,’ ‘A’, ‘P’ and ‘T’.
ii. Write a program that concatenate and print the following string (i), (ii), (iii) and (iv):
Week Eight
Program 14
Develop a computer program using C language to print numbers from 1 to 8 using do-while syntax
#include <stdio.h>
int i = 0;
do {
printf("%d\n", i);
i++;
}
11
while (i < 8);
Return(0);
Output:
Program 15
Write C program source code that will print serial numbers from 1 to 10 using for loop
Source code:
#include <stdio.h>
int main(){
int i;
return(0);
Output:
3
12
4
10
Exercise:
1. Use a for loop to write program that will print "Yes" 10 times
Week 9
Program 16
Write a program that change the Array index of 200 to replace 300 integer value and print it.
Source Code:
#include <stdio.h>
return(0);
Output:
Program 17
#include <stdio.h>
myNumbers[0] = 400;
return(0);
Output:
Exercise:
1. write a program that can create array stored of 20,30,60,80,10 and 200 and print all their index.
Week 10
Source code:
Program 18
#include <stdio.h>
void myFunction() {
int main() {
return(0);
Outputs
Write a C program that compute the power of number using math function to returns the value of x
to the power of y.
Source code:
#include <stdio.h>
#include <math.h>
int main () {
Return(0);
Output:
X to the power of y is 64
Week Eleven
Program 20
Write a program to execute the square root and round off numbers, use math functions
Source Code:
#include <stdio.h>
#include <math.h>
int main () {
printf(" The rounds off number upwards to its nearest integer is %f ", ceil(1.4));
printf("The rounds off number downwards to its nearest integer is %f", floor(1.4));
return (0);
Output:
The rounds off number downwards to its nearest integer 1.4 is 1.000000
Program.
16