aaa.c:
#include<stdio.h>
#include<unistd.h>
int main(void)
{
int i=0;
for(i=0;i<100;i++)
{
printf("%c", 'A');
usleep(200); //sleep in microsecs
}
return 0;
}
bbb.c
#include<stdio.h>
#include<unistd.h>
int main(void)
{
int i=0;
for(i=0;i<100;i++)
{
printf("%c", 'B');
usleep(200);
}
return 0;
}
ccc.c
#include<stdio.h>
int main(void)
{
char arr[2001];
scanf("%s",arr);
int i=0;
int size=sizeof(arr)/sizeof(int);
char c=arr[0];
int count=0;
for(i=0;i<size;i++)
{
if(c==arr[i])
{
count++;
}
else
{
printf("%c %d,",c,count);
c=arr[i];
count=1;
}
}
printf("\n");
return 0;
}
xyz.c
#include<fcntl.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/stat.h>
#include<sys/wait.h>
int main(int argc, char *argv[])
{
int mypipe[2];
int child1=1,child2=1,child3=1;
pipe(mypipe);
child1=fork();
child2=fork();
child3=fork();
if(child1==0)
{
close(mypipe[0]);
dup2(mypipe[1],1);
close(mypipe[1]);
execl("aaa","aaa",NULL);
perror("cannot start aaa");
return 1;
}
if(child2==0)
{
close(mypipe[0]);
dup2(mypipe[1],1);
close(mypipe[1]);
execl("bbb","bbb",NULL);
perror("cannot start bbb");
return 1;
}
if(child3==0)
{
close(mypipe[1]);
dup2(mypipe[0],0);
close(mypipe[0]);
execl("ccc","ccc",NULL);
perror("cannot start ccc");
return 1;
}
return 0;
}
output:
A 200,B 200,
Note: The order of the output may differ based on the architecture of the CPUs.
Suppose we have three programs aaa, bbb, ccc which are already developed, compiled and ready to...
Suppose that you have three programs that are suppose to print a house diagram in a collaborative manner. (i) prog1.c #include <stdio.h> /* Input/Output */ #include <stdlib.h> /* General Utilities */ int main() { printf(“ ^^^^^^^^^^^^ \n”); printf(“ ^^^^^^^^^^^ ^^^^^^^^^^^ \n”); printf(“^^^^^^^^^^^ ^^^^^^^^^^^ \n”); printf(“ | | \n”); printf(“ | | \n”); exit(1); } (i) prog2.c #include <stdio.h> /* Input/Output */ #include <stdlib.h> /* General Utilities */ int main() { printf(“ | | ...
C LANGUAGE PROGRAM: You have the program that creates a parent and child. They communicate via the pipe. The parent writes into the pipe and child reads the data from the pipe. All you got to is replace FILL_IN_THE_BLANK with appropriate values or function names and just type the values of each TASKS, I don't need the c program. TASK_1 = TASK_2 = TASK_3 = TASK_4 = 4 of them [ 5 points each ] -------------------------------------------------------------------------------------------- When you run the...
I have the following code....from the previous lab....the above
needs to be added to what is already existing. ALSO MODIFY
SEMAPHORES TO USE pthreads instead of the pipe constructs P() &
V()
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <sys/stat.h>
void printStat(char *filename);
//Main
int main(int argc, char *argv[])
{
//Process Id (storing)
pid_t pid;
int j;
//printf("Welcome to Project Three\n”);
// For loop*/
for (j = 1; j...
It is a C++ program by using
inheritance and vectors
My professor said that all the files should be separate. like
File.cpp, File.h, Text.cpp,Text.h,Main.cpp
I already have these files
File.cpp
#include "File.h"
// Constructor of File that takes File name and type as
arguments
File::File(string type, string name) {
this->type = type;
this->name = name;
}
//returns the type.
string File::getType() {
return type;
}
//returns the name of file.
string File::getName() {
return name;
}
File.h
#ifndef __FILE_H__
#define...
Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...
C++. Need some help getting started. We will also have the following two functions: 1. A mutate function that randomly modifies a chromosome. 2. A crossover function that takes two chromosomes and splits each one at the same spot, then combines them together. Our genetic algorithm works by iterating over generations of chromosomes via the following process: 1. Generate random population. 2. Until we get an answer that is good enough, do the next steps in a loop: (a) Do...
Help C++ Write a string class. To avoid conflicts with other similarly named classes, we will call our version MyString. This object is designed to make working with sequences of characters a little more convenient and less error-prone than handling raw c-strings, (although it will be implemented as a c-string behind the scenes). The MyString class will handle constructing strings, reading/printing, and accessing characters. In addition, the MyString object will have the ability to make a full deep-copy of itself...