// returns the length of str
int strLength(const char* str) {
int length = -1;
// we know that all strings in C must be null-terminated, so when a character of
// str is the null character, we have reached the end
while(str[++length]);
return length;
}
You can't. If you want to find the length of a String object, you must use at least one of the String methods. Simply iterate over your char* and count the number of characters you find before you reach the null character . int strLength(const char* str) { int length = 0; // take advantage of the fact that all strings MUST end in a null character while( str[length] != '\0' ) { ++length; } return length; }
to measture the length of objects
Yes, but never ever do it like this in real life: size_t mystrlen (const char *s) { if (s==NULL *s=='\0') return 0; else return 1 + mystrlen (s+1); }
Because you have to: any executable statement in C must belong to one function or another; there mustn't be executable statements outside of functions.and it also reduces the length of the program
A function is a small set of instructions designed to operate on its given input (aka parameters or arguments) and perform some action or return some output. Generally in programming a commonly used strategy is to take a large program and break it into smaller chunks, which are turned into functions. So say that you are writing a large program and constantly have to see which of two numbers is larger, you could write a function: int larger(int a, int b) { if(a > b) return a; else return b; } Now in your program, you can simply say: int x = larger(number1, number2);
They don't.
what is instruction length and what is instruction format and what is program length and what is the difference among them
The typical length of a thesis for a master's degree program is around 50-100 pages, but this can vary depending on the specific requirements of the program and the field of study.
HBO determines its programming by the length of the program and rating of the program.
The typical length of a PhD program in the USA is around 5 to 7 years, depending on the field of study and individual progress.
A typical thesis paper for a master's degree program is usually around 50 to 100 pages in length.
{Area s the area of cube} {Length is the length of one side of the cube} program AreaofCube; var Area,Length:real; begin write('Enter the length of cube: '); readln(Length); Area:=6*(Length*Length); writeln('The area of cube is ', Area, ' cm^2.'); end.