0% found this document useful (0 votes)
7 views

CS-2

The document contains a series of programming exercises related to shell scripting and C programming. It includes a correction task for a Bash script, an output explanation for a C program involving process IDs, and a request to write a Bash script that displays a multiplication table for a user-provided number. The document is structured with questions and code snippets for practical application of programming concepts.

Uploaded by

ahmed.waasel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CS-2

The document contains a series of programming exercises related to shell scripting and C programming. It includes a correction task for a Bash script, an output explanation for a C program involving process IDs, and a request to write a Bash script that displays a multiplication table for a user-provided number. The document is structured with questions and code snippets for practical application of programming concepts.

Uploaded by

ahmed.waasel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

:‫االسم‬ ‫جامعة صنعاء‬

‫كلية احلاسوب وتقنية املعلومات‬


:‫رقم القيد‬
‫نظم تشغيل عملي نؤةيؤ‬
:‫الدرجه‬
CS-G2

Q1:Correct The Error If Any:


#!/bin/bash
read -p "number : " $num
case num in $num
do
[1-5] )
Echo " number is less six" echo " " ;;
*)
echo "number is greater five" ;;
done esac
________________________________________________
Q2:write the output: pid=1234
#include <stdio.h>
Original Process: PID = 1234
#include <unistd.h>
Process: PID = 1235, Parent PID = 1234
int main() {
Process: PID = 1236, Parent PID = 1234
printf("Original Process: PID = %d\n", getpid());
Process: PID = 1237, Parent PID = 1235
fork();
Process: PID = 1238, Parent PID = 1235
fork();
printf("Process: PID = %d, Parent PID = %d\n", getpid(), getppid());
return 0;
}
_______________________________________________
Q: Write a shell scripting program
Write a Bash script that does the following:
Asks the user for a number.
Display the multiplication table for a specific number

#!/bin/bash
echo "Enter a number to display its multiplication table:"
read number
echo "Multiplication Table for $number:"
for i in {1..10}
do
result=$((number * i))
echo "$number x $i = $result"
done

You might also like