What is the difference between local variable and global variable in Embedded C?
It's simple. A global variable has a scope through out out the C program. It can be accessed anywhere from any function or etc. A local variable on the other hand, is local to it's container only and can not be accessed outside of it's container. For example a function has variable sum then sum is only accessible within the function and not anywhere else.
What are the limitations of return statement in c language?
The only limitation is that the object returned from a function must be returned by value. We may return a pointer (by value) in order to return complex objects more efficiently, however the pointer must not refer to a non-static local object because non-static local objects fall from scope as soon as the function returns.
In C++ we do not have this problem because objects can be implemented with efficient move semantics, thus passing by value becomes an efficient means of returning complex objects from functions, including non-static local objects.
Which programming language should you use?
Depends on what you are trying to program! Games, web applications, mobile phone apps may use different languages. I'm not sure which ones use which as of 11-2009 but you need to determine that first!
A c program to generate a series of 1 3 6 10 15 21.?
As you can see, this series is the sum of the sequence: 1, 2, 3, 4, 5, 6.
That is to say:
1 + 2 = 3
3 + 3 = 4
6 + 4 = 10
10 + 5 = 15
15 + 6 = 21
To program this in C, you would want a simple incremental counter which would be added to the series sum on each iteration of the loop.
{
int c = 2;
int sum = 1;
// loop until you find all the numbers you want
while(1) {
// increase the running sum to find the next next number in the series
sum += c;
// increment our counter
++c;
}
}
What are the advantages of Turbo C plus plus?
The only reason to use Turbo C++ as opposed to, say, Visual C++ is because you chose to use a Borland IDE rather than a Microsoft IDE. If the question is why we use C++ rather than a specific IDE, then it is because we want high performance without all the the complexity of a low-level symbolic language such as assembler. If performance were not an issue, we would choose to use a more abstract, high-level language such as Java instead, which is ideally suited to rapid application development, but unsuitable for high-performance applications.
You need to scan through the string and keep track of the vowelsoccurring. Here is a sample program:
#include
#include
int countVowels(char[] s){
int count = 0, i;
for( i=0; char[i] != '\0'; i++){
switch(char[i]){
case 'a':
case 'e':
case 'i':
case 'u':
case 'o': count++;break;
}
}
return count;
}
int main(){
char str[256];
printf("Enter the string:\t");
scanf("%s", str);
printf("The number of vowels in the string are :%d\n", countVowels(str));
return 0;
}
How can you print any statement without using semi column in c programming language?
I know this can be done or your teacher would not have given this question as homework.
The truth is I do not have a clue how to do this because in the real world it is not necessary to know or be able to do this. Ask your teacher or read your text book.
What are the political functions of a language?
When a Language is well developed then If any political party arises between that language people then the political group will be a linguistic group. The political group will support the customs followed the language speakers. thus they become supporters of the particular group people thus the gain popularity. Language influences the activities of the political group.. I mean the Literature plays a key role as the people follow the practices mentioned in their literature. If you arent satisfyied I'm sorry. Have a good day!!
What is the difference between system call and library function call?
On one level, there is no difference. They are both function calls. The only difference is in what they do.
System calls do something the user program cannot do; something having to do with system resources: memory, files, devices, network, terminals, processes etc.
However, system calls are usually implemented by library function calls because, at the root of the matter, a C or C++ program can only invoke function calls to call upon the operating system to do things.
There are only 5 built-in types in C. They are char, int, float, double and void. All other types are modified types, user-defined types, or aliases (typedefs). If a modified type does not specify a type, int is assumed, thus a long is a long int while a short is a short int. Both char and int can be modified with the signed or unsigned modifiers. The float and double types are always signed but a double can be modified with long to create a long double. User-defined types include structs and unions. All types can be further modified with the suffix operator to create arrays of the given type. Furthermore, all types can be prefixed with the pointer operator to produce a pointer of the given type.
No. Windows and Linux have different APIs and ABIs for programs to access. You cannot run Linux binaries on Windows, and you can only run Windows binaries on Linux if you have Wine installed.
What is the difference of non void and void function?
If a method call is void, that means it will not return a data value to a program that calls it. Otherwise, the method is expected to return a data value of some sort.
For example, if I have a method called print() that is void, and the body of the method has a command to print a word to the screen, the method will run that command and end.
However, if I have a method called add(int x, int y) that takes two numbers and adds them together, the program calling this method wants an answer back. So this method is not void.
Write a program to search an element in an array using binary search?
Shell script to check if a string is a palindrome?
Computer Programming QuestionsAnswers.com> http://wiki.answers.com/../ > http://wiki.answers.com/FAQ > http://wiki.answers.com/FAQ/3776> http://wiki.answers.com/FAQ/458> http://wiki.answers.com/FAQ/2096
View Slide ShowBest Answer
len=0
i=1
echo -n "Enter a String: "
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
halfLen=`expr $len / 2`
while [ $i -le $halfLen ]
do
c1=`echo $str|cut -c$i`
c2=`echo $str|cut -c$len`
if [ $c1 != $c2 ] ; then
echo "string is not palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
echo "String is Palindrome"
What are the real time applications of binary search tree?
Even though the bounty is gone, since the accepted answer gives the extremely-false impression that binary-trees are not very useful, I will post another answer.
To squabble about the performance of binary-trees is meaningless - they are not a data structure, but a family of data structures, all with different performance characteristics. While it is true that unbalanced binary trees perform much worse than self-balancing binary trees for searching, there are many binary trees (such as binary tries) for which "balancing" has no meaning.
The reason that binary trees are used more often than n-ary trees for searching is that with every comparison in a (balanced) binary tree, you eliminate about half the tree from consideration. In contrast, with an n-ary tree, you can eliminate (n-1)/n of the tree using log(n) comparisons (using a binary search).
Applications of binary treesHow are elements of an array stored in memory?
Computer memory is linear so a one dimensional array can be mapped on to the memory cells in rather straight forward manner.To find the actual address of an element one needs to subtract one from the position of the desired entry and then add the result to the address of the the first cell in the sequence.Having said that therefore it is necessary to know the starting address of the space allocated to the array and the size of the each element, which is same for all the elements of an array.The the location of the Ith element would be B+I*S
where B is the base address(Starting address of the array) and S is the size of each element of the array.
What purpose do braces serve in C programming?
grouping statements. eg:
if (i==2) printf ("i==");
printf ("2");
and
if (i==2) {
printf ("i==");
printf ("2");
}
do different things, if i<>2
What steps are required form an algorithm to convert a binary number to it's decimal equivalent?
Let's look at an example. If you want to convert the number 100112 to decimal you can split up the number so each digit has an index associated to it:
4 3 2 1 0
1 0 0 1 1
We can then find the decimal value:
24 * 1 + 23 * 0 + 22 * 0 + 21 * 1 + 20 * 1 =
16 * 1 + 8 * 0 + 4 * 0 + 2 * 1 + 1 * 1 = 16 + 0 + 0 + 2 + 1 = 19
So what we need to do is to multiply each of the binary digits by the value of two raised to the index of the digit. This will give you the conversion from any binary number to a decimal number.
What are the differences between thread and function in C plus plus?
As people do computer has head to think and hands to work. Under the control of it's head(CPU), you can consider threads as its hands. A computer has more than one hand, every hand would do one thing independently but have to wait its order. Function, as it demonstrate by the name, means what task a software can conduct.
How do you reverse the order of the elements in the array?
Start by pointing to each end of the array. Work your way towards the middle of the array, swapping elements as you go. When the pointers meet or pass each other, the array is completely reversed.
Program to shut down a PC in c?
Well C language is a programming language it is used for designing programs. So you must be confused i can tell you how to shut your computer down using the command prompt though
*Step one open start and click run type cmd and press enter
*step two once the command prompt has opened type shutdown -i and press enter a dialogue box will appear
*Step three at the top of the box there is a button that says ADD click that and type your computers name if if you do not know your computers name opn the control panel then open system and choose the tab on the top that says computer name your computers full name will be located here
*Step four copy and paste your computers name into the box that popped up when you clicked add click ok now your computers name has been added to the list now from the drop down menu select what you want your computer to do restart shut down etc.
type a comment and select ok your computer should shutdown
Explain the structure of c program with an suitable example?
Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main()
{
Declaration part Executable part (statements)
} /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) .
.
. (return type) (function name n) (arguments...) Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main()
{
Declaration part Executable part (statements)
} /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) .
.
. (return type) (function name n) (arguments...)
What is the meaning of percent s in C programming?
%d is used as a format mask to represent an integer.
Any of the "formatted" io functions can use this: printf, fprintf, scanf, etc.
Example:
int i = 0;
printf("%d", i); // prints the value of i
This is a format specifier which is used to identify that the given input is an integer or not
In C: c%d means the remainder dividing c with d
in printf/scanf format string: %d means an integer data
For extracting or inserting data which is signed integer in decimal format