Work related, C/C++ Programming

Make the following 3 functions work by filling in appropriate C code. This file


1.
// Write a function to count the number of particular characters in a string.
// Do not use any standard library calls.
int CountCharacters(char* String, char Character)
{
//insert your code here
}

// 2.
// Write a function that reverses a string without allocating any extra storage.
void ReverseString(char* String)
{
//insert your code here
}

// 3.
// Write a function that returns the nth prime number corresponding to the number n passed.
// • Do not worry about overflow. Assume that a long will hold all required values.
// • Optimize for readability and compactness, not speed.
// • Do not use any complex math formulas to calculate it.
// • Do not use any math operators beyond addition, subtraction, multiplication, division.
// • I''m looking at your coding ability, not your math ability or your ability to go look up an algorithm on Google.
//
// Examples:
// GetPrime(1) == 2 // the first prime number is 2
// GetPrime(2) == 3 // the second prime number is 3
// GetPrime(3) == 5 // the third prime number is 5
// GetPrime(4) == 7 // the fourth prime number is 7
// GetPrime(5) == 11 // the fifth prime number is 11
// GetPrime(1000) == 7909 // the thousandth prime number is 7909
long GetPrime(long n)
{
//insert your code here
}
Posted Date: 3/26/2013 8:48:53 PM | Location : United States







Related Discussions:- Work related, Assignment Help, Ask Question on Work related, Get Answer, Expert's Help, Work related Discussions

Write discussion on Work related
Your posts are moderated
Related Questions
Why shouldn't Matrix class's interface look like an array-of-array? A: Some people build a Matrix class that has an operator[] that returns a reference to an Array object (or po

one of the segments is showing compilation error...

Question: a) Give two uses of NFS. b) Give one advantage of using NFS. c) Explain the following lines as they would be interpreted in the /etc/exports file i. /usr/local

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b


Input Format: First line starts with T, which is the number of test cases. Each test case contains a string (S). Output Format: For each test case print the minimum number of ch

I need Decompile Library(.DLL or .SO) into source code Project Description: I am seeking an experienced programmer or anyone who knows a thing or two about reverse engineerin

1) Database: The database needs to be used for persistent storage of cars. For details of what information should be stored in the database, please see the description above. You

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Define the following Window class : - integer  data members, width and height - a constructor  that accepts two integer  parameters  (width followed by height) and uses them to ini