Operating System Concepts Lab: Saleem Mustafa
Operating System Concepts Lab: Saleem Mustafa
Operating System Concepts Lab: Saleem Mustafa
Lab
Prepared by
Saleem Mustafa
[email protected]
1. Print “Hello World” in C language and compile on terminal
#include <stdio.h>
int main()
{
printf( "Hello World" ); //Printing output on Screen
return 0;
}
On Terminal type for Output:
gcc filename.c –o
./a.out
int main()
{
printf( "My name is Rayaan\n"); //Printing output on Screen
printf( "Superior University Lahore");
return 0;
}
On Terminal type for Output:
gcc filename.c –o output
./output
int main()
{
int num;
printf( "Please enter a number: " ); //Printing output on
Screen
scanf( "%d", &num ); //taking input from
user
printf( "You entered %d", num );
return 0;
}
On Terminal type for Compilation and Execution:
gcc filename.c –o output
./output
#include <stdio.h>
int main()
{
int n, i, flag = 0;
printf("Enter a positive integer: ");
scanf("%d",&n);
-----------------------------------------------------
result = sum(number);
printf("sum=%d", result);
}
-------------------------------------------
Task No. 1:
Write a program in C language which calculate the factorial of positive number. And write
program to find prime number by taking input as numbers.
Task No. 2:
Write a program in C language which find prime number from the numbers taken from user and
compile and execute on terminal in Ubuntu.
Task No. 3:
Write a program in C language which perform the recursion operation on numbers taken from
user also compile and execute on terminal in ubuntu.