Please answer the following C question:
There is a documented prototype for a function called
get_a_line...
Please answer the following C question:
There is a documented prototype for a function called
get_a_line in the code below. Write a definition for get_a_line—the
only function called from that definition should be
fgetc.
#include <stdio.h>
#include <string.h>
#define BUFFER_ARRAY_SIZE 10
int get_a_line(char *s, int size, FILE *stream);
// Does what fgets does, using repeated calls to fgetc, but
// provides a more useful return value than fgets does.
//
// REQUIRES
// size > 1.
// s points to...
Consider the following function:
double arrayavg(int a[], int n){
int sum=0;
for(int i=0; i!=n; ++i){
sum+=a[i];...
Consider the following function:
double arrayavg(int a[], int n){
int sum=0;
for(int i=0; i!=n; ++i){
sum+=a[i];
}
return (double)sum/n;
}
Rewrite the function to eliminate the array subscripting (a[i]),
using pointer arithmatic instead.
Write a program that reads a line of input and checks if it is
a palindrome (ignoring spaces)
Write a program that takes the name of a file as a command line
argument, and prints the contents of the file (similar to the linux
'cat' program).
Write...
Give the output of the following program. Then explain what the
foo() method does, in general,...
Give the output of the following program. Then explain what the
foo() method does, in general, for a given input. Is foo() a
tail-recursive method? Why or why not?
class SomeThing {
public static void main(String args[]) {
System.out.println(foo(6));
}
private static int foo(int input) {
if (input <= 0)
{
throw new RuntimeException("invalid input");
}
else if (input == 1)
{
return 1;
}
else if (input %...
This is my code and can you please tell me why it's not
working?
By the...
This is my code and can you please tell me why it's not
working?
By the way, it will work if I reduce 10,000,000 to
1,000,000.
#include <iostream>
using namespace std;
void radixSort(int*a,
int n)
{
int intBitSize =
sizeof(int)<<3;
int radix = 256;
int mask = radix-1;
int maskBitLength = 8;
int *result = new
int[n]();
int *buckets = new
int[radix]();
int *startIndex = new
int[radix]();
int flag = 0;
int key = 0;
bool hasNeg =...
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...
It is N
queens problem please complete it
use this
code
//***************************************************************
// D.S.
Malik
//...
It is N
queens problem please complete it
use this
code
//***************************************************************
// D.S.
Malik
//
// This
class specifies the functions to solve the n-queens
//
puzzle.
//***************************************************************
class
nQueensPuzzle
{
public:
nQueensPuzzle(int queens = 8);
//constructor
//Postcondition: noOfSolutions = 0;
noOfQueens = queens;
// queensInRow is a pointer to the
array
// that store the n-tuple.
// If no value is specified for the
parameter queens,
// the default value, which is 8, is
assigned to it.
bool...
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE?
QUESTION: This program reads integers from standard
input....
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE?
QUESTION: This program reads integers from standard
input. The first
integer indicates the number of values that will follow.
Read that many values, and return their sum, ignoring any
additional values that may follow. However, if there
are
fewer integers than specified in the input, print "Error"
and terminate.
Hint:
int n, success;
...
success = scanf("%d", &n); // FIRST INTEGER INPUT
reads an integer from stdin, returning 1 if the integer...
CS4315 Operating Systems
Lab 2: Linux Processes
This lab assignment contains three questions.
To submit this...
CS4315 Operating Systems
Lab 2: Linux Processes
This lab assignment contains three questions.
To submit this lab assignment, please use a Word document to
include the
screenshots and write your answer.
1. Run the following C program, and submit a screenshot of the
result.
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int main( )
{
pid_t pid;
if ( (pid = fork()) == 0 )
{
printf (“I am the child, my pid = %d and my parent
pid = %d\n”,...