Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2.1.3 Sum of squares of first hundred natural numbers with different cores
//gcc 7.4.0 #include <stdio.h> #include <stdlib.h> #include <omp.h> int main(void) { int i,n = 100,sum1 = 0,sum2 = 0; #pragma omp parallel #pragma omp sections { #pragma omp section { for (i = 1;i <= 50;i++) { sum1 = sum1 + (i*i); } } #pragma omp section { for(i = 51;i <= n;i++) { sum2 = sum2 + (i*i); } } } int sum = sum1 + sum2; printf("Sum using First core = %d",sum1); printf("\nSum using Second core = %d",sum2); printf("\nTotal sum in Main Thread = %d",sum); return 0; }
run
|
edit
|
history
|
help
0
Finding the second largets value v0.5
B_141209_TrianguloTartalia
PI
Lab 6 v1
Hello world.c
String operations in C (without using built-in methods)
Project 3 Part 1 v2
sum of arrays
a1
fork