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
write a prgm to find minimum total number of shelves including the intial one required for loading process

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

a palindrome is a string that reads the same from bhote the ends

Create a class  called  ticketSelling that stores booking information of a single performance on a single day and sells the tickets of the performance. The class should include at

Write a program to calculate e^x using the formula: e^x = 1 + x/1! + x^2/2! + x^3/3! + ...... Allow the user to enter the integer number x, then do the calculation in a loop (for

Explain each of the algorithms in a way that would be understandable to an intelligent person who is not familiar with programming. You should not use any code (or even pseudo code

Reverse a string - C ++ program: Write a program in c to reverse a string. int main() {     Stack theStack;     String reverse("reverse");       cout

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Operators in C++: All C operators are valid operators in C++ also.  Besides C++ has developed some new operators like Operators and their Expression: 1.      Logical op

write a C rpogram that can display the transpose form of a ciphertext matrix.Prompt users to provide row and coloumn number of matrix.Then user will input plaintext and the program