Untitled
unknown
plain_text
a year ago
1.6 kB
8
Indexable
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
using namespace std;
int katrori(int x)
{
return x*x;
}
int kubi(int x)
{
return x*x*x;
}
int fuqiakatert(int x)
{
return x*x*x*x;
}
int trefishi(int x)
{
return x+x+x;
}
int main() {
int numri=2;
pid_t pid1, pid2, pid3;
if((pid1=fork())<0)
cout<<"Femija1 nuk eshte krijuar me sukses "<<endl;
else
{
int rezultati = katrori(numri);
cout<<"Procesi femije1 ka numrin : "<<getpid()<<endl;
cout<<"Katrori u llogarit nga femija1 dhe rezultati eshte "<<rezultati<<endl;
}
if((pid2=fork())<0)
cout<<"Femija2 nuk eshte krijuar me sukses "<<endl;
else
{
int rezultati = kubi(numri);
cout<<"Procesi femije2 ka numrin : "<<getpid()<<endl;
cout<<"Kubi u llogarit nga femija2 dhe rezultati eshte "<<rezultati<<endl;
}
if((pid3=fork())<0)
cout<<"Femija3 nuk eshte krijuar me sukses "<<endl;
else
{
int rezultati = fuqiakatert(numri);
cout<<"Procesi femije3 ka numrin : "<<getpid()<<endl;
cout<<"Katrori u llogarit nga femija3 dhe rezultati eshte "<<rezultati<<endl;
}
else{
int rezultati=trefishi(numri);
cout<<"Procesi prind ka numrin : "<<getpid()<<endl;
cout<<"Kubi u llogarit nga prindi dhe rezultati eshte "<<rezultati<<endl;
wait(NULL);
cout<<"Femija ka perfunduar"<<endl;
}
return 0;
}Editor is loading...
Leave a Comment