How to create a completely responsive Online eLearning – Education – Training Website Design Template using HTML CSS and JavaScript. **Training Website Template Free Download**

Now I will use the pointer variable in both processes in the same way as I normally use it.

Here is the code to access the same variable from two different programs. I will push the value from one program, access the value of that variable from another program.

Code to write value to variable: write.c

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <sys/ipc.h>

#include <sys/shm.h>

#include <errno.h>

#include <unistd.h>

int main() {

key_t sharedKey;

int shmId, *sharedVariable;

char path[100], command[100];

snprintf(path, sizeof(path), “/rnd/sharedMemory/sharedKey.txt”);

snprintf(command, sizeof(command), “touch /rnd/sharedMemory/sharedKey.txt”);

system(command);

sharedKey = ftok(path, ‘m’);

if (sharedKey == -1) {

error(“Shared Key Generation: “);

return 0;

}

shmId = shmget(sharedKey, sizeof(int), 0666 | IPC_CREAT);

if (shmId == -1) {

error(“Shared Memory ID: “);

printf(“%s %d\n”, strerror(errno), errno);

return 0;

}

else if (shmId >= 0) {

snprintf(command, sizeof(command), “echo \”%d\”>>shmid.txt”, shmId);

system(command);

}

sharedVariable = (int *)shmat(shmId, NULL, 0);

if (sharedVariable < 0) {

error(“Shared Value Memory Attachment: “);

return 0;

}

*sharedVariable = 2;

printf(“Data written in memory: %d\n”, *sharedVariable);

shmdt(sharedVariable);

return 0;

}

Code to read value from variable: read.c

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <sys/ipc.h>

#include <sys/shm.h>

#include <errno.h>

int main() {

key_t sharedKey1;

int shmId, *sharedVariable;

char path[100];

snprintf(path, sizeof(path), “/rnd/sharedMemory/sharedKey.txt”);

sharedKey1 = ftok(path, ‘m’);

if (sharedKey1 == -1) {

error(“Shared Key Generation: “);

return 0;

}

shmId = shmget(sharedKey1, sizeof(int), 0);

if (shmId == -1) {

error(“Shared Memory ID: “);

printf(“%s %d\n”, strerror(errno), errno);

return 0;

}

sharedVariable = (int *)shmat(shmId, (void*)0, 0);

if (sharedVariable < 0) {

error(“Shared Value Memory Attachment: “);

return 0;

}

printf(“Data read from memory: %d\n”, *sharedVariable);

shmdt(sharedVariable);

shmctl(shmId,IPC_RMID,NULL);

return 0;

}

Now if the read.c code is run after running the write.c code, it will be seen that although no value is assigned to the sharedVariable variable anywhere in the read.c, the variable is getting the value assigned in the write.c. And in this way, through inter process communication (ipc), any change made by one process can be received from another process.

**Training Website Template Free Download**

UVA 106 : Fermat Vs. Pythagoras

Problem:

You will be given an integer n. You need to find the number of Pythagorean Triples smaller than n, which are Relatively Prime, that is, whose GCD (Greatest Common Divisor) is 1. You also have to find out which integers smaller than n will not have any triples, their number (for this part, even if they are not relative primes, they must be counted).

If the input is,

10

25

100

The output will be:

1 4

4 9

16 27

Each output has two portions. Explanation for input 10. For First Portion:- There is only one Pythagorean triple from 1 to 10 which is relatively prime. They are (3, 4, 5). So the output is 1. There is another Pythagorean Triple (6,8, 10), which is not Relatively Prime, that is, there are a total of 6 numbers between 1 and 10, which are part of some Pythagorean Triple (3, 4, 5, 6, 8, 10). Four numbers (1, 2, 7, 9) do not fit into any triple, so 4 appears in the second part of the output.

Problem Link: UVA 106

Although the problem says, the maximum value of n in input can be 1000, but from discuss, the maximum value of n can be 10^6. I got a few runtime errors due to this incorrect statement. 😦 The Time Complexity of the solution was also very bad. Later I got to know from Discuss that n<=10^6 can be.

How to do?

Assuming, (a, b, c) is a Pythagorean Triple,

An interesting fact about Pythagorean Triples is that if (a, b, c) is a Pythagorean Triple, then it is also true that (ka, kb, kc) is also a Pythagorean Triple, where k is a Positive Integer. For example, since (3, 4, 5) is Pythagorean Triple, so (6 , 8 , 10 ), (9 , 12 , 15 ), (12, 16, 20) …. Thus it is true for any k-multiplier.

So my idea for this problem is, whenever I get any Pythagorean Triple, I will mark the numbers of Pythagorean Triple along with all k multiples of Pythagorean Triple up to n. Even if you don’t understand now, there is no problem, I hope, after reading the entire post, the solution will be clear, Insha’Allah. 🙂

The question is, how do I get those Pythagorean Triples, which are Relatively Prime? For this, let’s take a look at some of my things first:

Since Pythagorean triples are relatively prime, it is impossible for all three of a, b & c to be even. Because, then this triple is no longer relatively prime.

Only a & b cannot be even, because then the sum of a^2 & b^2 will also be even.

Any one of a & b is even but the sum of a^2 and b^2 is even, which is also not possible, because the sum of the square of an even number and the square of an odd number can never be even.

From 2 and 3 above, we can say that any two of the Pythagorean Triple cannot be even.

This point is the most important, so I am explaining it separately later. The point is, both a & b can never be odd together.

Explanation of point no. 5:

If our Pythagorean Triple is (a, b, c), then a^2 + b^2 = c^2. Now if both a & b are odd, then the sum of their squares must be even. hold on

a=2x+1

b=2y+1

c=2z

then,

a^2 + b^2 = c^2

=> (2x+1)^2 + (2y+1)^2 = (2z)^2

=> 4x^2 + 4x + 1 + 4y^2 + 4y +1 = 4z^2

=> 4x^2 + 4y^2 + 4x + 4y +2 = 4z^2

=> x^2 + y^2 + x + y + \frac { 1 }{ 2 } = z^2

From the above solution, if a & b are both odd and c is even, then a, b & c -> together cannot all be Integer. But to be Pythagorean Triples, a, b & c must all be integers. That is, if a & b are both odd and c is even – not possible. For more explanation, see this question and answer on math.stackexchange.com. 🙂

We have so far concluded that either a & b must be even, assuming a is even. Then write a^2 +b^2 = c^2 as,

a^2 = c^2 – b^2

It can be rewritten as,

Since, a is an even number, a^2 must be divisible by 4. Again (c + b) & (c – b) are even numbers, because addition/subtraction of two odd numbers will always be even. So the above equation can be written as,

In the above equation (\frac{c+b}{2}) and (\frac{c-b}{2}) must be relatively prime. Because, if they are not relatively prime, then c & b cannot be relatively prime. See this question and answer on math.stackexchange.com for more explanation.

**Training Website Template Free Download**

Now see, in the above Equation, a square number is shown as the product of two such numbers, which are relatively prime. From this we can say, (\frac{c+b} {2}) and (\frac{c-b} {2}) – each of them is actually a square number. I am explaining it below:

Look, when prime factorizing a square number, you will see that there are even number of prime factors. The previous statement is true for any square number. Eg: Prime factors of 100 (square of 10) are 2 and 5. Now in 100 2 has 2, 5 has 2. Thus, you see how many times the prime factors of any square are in that square number. As you can see, those numbers will always be even. (Well, why is that? Think about it. 🙂 What about density? Or other powers? )

Now since (\frac{c+b} {2}) and (\frac{c-b} {2}) are Relatively Prime, i.e. they have no common factor except 1, so {(\frac{a}{2}) For }^2 to be a square, (\frac{c+b} {2}) and (\frac{c-b} {2}) must each have an even number of prime factors. Otherwise the prime factors of {(\frac{a}{2})}^2 will not be even.

## Before Download

## You must Join our Facebook Group and Subscribe YouTube Channel

**All Links in Below:**

**Join Our FreeWebsiteCreate Facebook Group to get an instant update for projects, templates, design resources, and solutions.**

**Join Our YouTube Channel & Subscribe with Bell Icon for New Video:**

## Join Our Official Facebook Page For the Latest updates All Code Projects are Free:

## Visit our service page to get **premium services.**

Free Website Create – HTML CSS, PHP, JavaScript Programming Projects For Free

**Follow Us**

**Thank You,**

## Before Download

## You must Join our Facebook Group and Subscribe YouTube Channel

FreeWebsiteCreate.net tries to provide HTML, CSS, SCSS, JavaScript, React, Android Studio, Java, PHP, Laravel, Python, Django, C#(C Sharp), and ASP.net-related projects 100% free. We try to make learning easier. Free Website Create always tries to give free projects to new learners. Free projects and source code will help to learn quickly.

They can save time and learn more. In this post, we share a free portfolio project website code with HTML and CSS. This free code portfolio contains a single landing page with a responsive design. In this post, we get a free best carpenter and craftsman service website designed by FreeWebsiteCreate with HTML, CSS, Bootstrap, and JavaScript.