Please explain what will be printed out at LINE1 and LINE2?
#include <stdio.h>
#include <types.h>
int...
Please explain what will be printed out at LINE1 and LINE2?
#include <stdio.h>
#include <types.h>
int data[4] = {1,3,5,7};
void *runner (void *param);
int main(int argc,char *argv[])
{
pid_t pid;
pthread_t tid;
pid = fork();
if (pid==0){
pthread_create(&tid,NULL,runner,NULL);
pthread_join(tid,NULL);
for(int i=0,i<4,i++)
printf("from child process, the values at i is %d",data[i]);
}
else if (pid>0){
wait(NULL);
for(int i=0;i<4,i++)
printf("from parent process, the values at i is %d",data[i]);
}
}
void *runner(void *param){
for(int i=0;i<4,i++)
data[i]+=3*i;
pthread_exit(0);
}
}
}
}
}
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 extern char **environ;
5 void output(char *a[], char...
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 extern char **environ;
5 void output(char *a[], char *b[]) {
6 int c = atoi(a[0]);
7 for (int i = 0; i < c && b[i]; ++i)
{
8 printf("%s", b[i]+2);
9 }
10 }
11
12 void main(int argc, char *argv[]) {
13
14 switch (argc) {
15 case 1:
16 for (int i = 0; environ[i]; ++i)
{
17 printf("%s\n", environ[i]);
18 }
19 break;
20 default:
21 output(argv +...
#include <stdio.h>
extern unsigned long long sum(unsigned int *array, size_t
n);
int
main(void)
{
unsigned int...
#include <stdio.h>
extern unsigned long long sum(unsigned int *array, size_t
n);
int
main(void)
{
unsigned int array[] = { 1, 1, 1, 3 };
unsigned long long r = sum(array, sizeof(array) /
sizeof(*array));
printf("Result is: %llu (%s)\n", r, r == 6 ? "correct" :
"incorrect");
return 0;
}
Complete the code for the line that calls the sum function.
Write the sum function.
Run the below code and shift binary left and right and
understand the output.
#include <stdio.h>...
Run the below code and shift binary left and right and
understand the output.
#include <stdio.h>
int main()
{
int num=212, i;
for (i=0; i<=2; i++)
printf("Right shift
by %d: %d\n", i, num>>i);
printf("\n");
for (i=0; i<=2; i++)
printf("Left shift by
%d: %d\n", i, num<<i);
return 0;
}
Output:
Translate C code into MIPS. Do not include an exit syscall
int proc1( int a, int...
Translate C code into MIPS. Do not include an exit syscall
int proc1( int a, int b ) {
if ( proc2( a, b ) >= 0 )
return 1;
else
return -1;
}
int proc2( int a, int b ) {
return (a*10) & (b*10);
}
int main() {
int a = 9;
int b = -10;
int c = a + b + proc1( a, b );
printf("%d\n", c );
return 0;
}
can someone edit my c++ code where it will output to a file. I
am currently...
can someone edit my c++ code where it will output to a file. I
am currently using xcode.
#include <iostream>
#include <cctype>
#include <cstring>
#include <fstream>
using namespace std;
bool inputNum(int [],int&,istream&);
void multiply(int[],int,int[],int,int[],int&);
void print(int[],int,int,int);
int main()
{ifstream input;
int num1[35],num2[35],len1,len2,num3[60],len3=10,i;
input.open("multiplyV2.txt"); //open file
if(input.fail()) //is it ok?
{ cout<<"file did not open please check it\n";
system("pause");
return 1;
}
while(inputNum(num1,len1,input))
{inputNum(num2,len2,input);
multiply(num1,len1,num2,len2,num3,len3);
print(num1,len1,len3,1);
print(num2,len2,len3,2);
for(i=0;i<len3;i++)
cout<<"-";
cout<<endl;
print(num3,len3,len3,1);
//cout<<len1<<" "<<len2<<"
"<<len3<<endl;
cout<<endl;
}
system("pause");
}
void...