answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

TCS230 sensor code in embedded c?

i dont know please give some idea to develope in sensor coding

Why do you use hashing and not array?

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

What is meant by the following statement A repeater is limited not only in function but also in scope?

A repeater contains one input port and one output port, so it is capable only of receiving and repeating a data stream.

Addition of matrix using arrays in c?

#include<stdio.h>

int main(){

int a[3][3],b[3][3],c[3][3],i,j;

printf("Enter the First matrix->");

for(i=0;i<3;i++)

for(j=0;j<3;j++)

scanf("%d",&a[i][j]);

printf("\nEnter the Second matrix->");

for(i=0;i<3;i++)

for(j=0;j<3;j++)

scanf("%d",&b[i][j]);

printf("\nThe First matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",a[i][j]);

}

printf("\nThe Second matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",b[i][j]);

}

for(i=0;i<3;i++)

for(j=0;j<3;j++)

c[i][j]=a[i][j]+b[i][j];

printf("\nThe Addition of two matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",c[i][j]);

}

return 0;

}

What are the four file commands to read and write to a file?

Please refine your question, it is not precise enough to get a clear understanding of what you are asking.

What will be the prototype of a user defined function?

In C programming, there are no built-in functions; all functions are user-defined. In order to use a function it must first be declared. This can be achieved by importing the header file containing the declaration (via the #include compiler directive) or by typing the declaration by hand.

The definition (implementation) of a function is not required in order to use a function, but if a function is used it has to be defined somewhere (undefined functions will cause a link error). Where a function is used by several translation units, placing the declaration in a header file ensures the declaration is consistent across all translation units. Grouping declarations by purpose allows us to import several declarations at once. Declarations that are not used are simply ignored.

A declaration informs the compiler of the function's name and type, and the number and type of its arguments, if any. This describes the interface to the function. A function's type is denoted by its return type. A function that has no return value is simply declared void (no type). The return type always comes first in a declaration, followed by the function name, which must be a unique identifier within the scope in which it is declared (global or local scope). A local name will mask a global name, effectively hiding it from the local scope.

Function arguments (the formal arguments of the function) are delimited by parenthesis after the function name. A single argument of type void denotes no arguments while multiple argument types must be separated by commas (void types are not permitted in a multiple argument function). The complete declaration is terminated by a semi-colon immediately after the closing parenthesis. If the declaration is also a definition, the function body (the implementation) replaces the closing semi-colon.

To assist with documentation, the formal arguments of a declaration may be named (unless the argument is void). However, where names are given, they need not match the corresponding names provided by a function's definition, where defined separately. Using longer descriptive names in the declaration helps document their purpose, while the definition can use shorter names that are easier to work with.

What is the different between break and continue?

The break statement exits out of the smallest containing loop or switch-case statement. The continue statement transfers control to the next iteration of the smallest containing loop statement.

What is a green operators license disc?

A green operator's license disc is a permit issued by certain regulatory authorities, allowing operators of vehicles, particularly in the transportation sector, to legally operate their vehicles under specific environmental standards. The green color typically signifies compliance with eco-friendly practices, such as reduced emissions or the use of alternative fuels. This disc is often displayed on the vehicle to indicate its adherence to regulations aimed at promoting sustainability and reducing environmental impact.

Why is this statement an example of faulty logic?

Its not a statement of faulty logic because it is a question not a statement, also its not comparing anything so that is why i think its not a faulty statement

What is the difference between runtime errors and compile time error?

Compile time errors occur do to syntax errors (such as forgetting a semi-colon at the end of a line) and they prevent your program from even compiling.

A runtime error is an error in logic in your program. Your program will compile, however while running the program it will throw an error because it tries to do something illegal (such as dividing by 0).

How do you write a program to delete all the vowels from a sentence assuming the sentence is no more than 80 characters long?

There is no need to assume the length if the sentence is represented by a null-terminated string. The following function will strip out all the vowels in any null-terminated string of any length, returning the number of vowels removed. Note that we don't create a new string, we simply modify the existing one since we know the modified string cannot be any longer than the existing one. If you want to retain the original string, simply make a copy of it before invoking this function.

The p variable is a pointer and will initially refer to the first character of str, which is also a pointer. The cnt variable maintains a count of the vowels we removed. We use the str pointer to advance through the string one character at a time. When str is referring to a vowel we simply advance str to the next character leaving p where it is (effectively ignoring the vowels) and increment cnt. When str refers to a non-vowel, we copy the character from str to p and advance both pointers. When str reaches the null-terminator, we place a null-terminator in p and return the value of cnt.

If any vowels were found there will be cnt characters beyond the new null-terminator. If the original string was a fixed-length array then you cannot remove these extra characters, but for variable length strings you may wish to reallocate, reducing the size of the allocation by cnt characters.

int strip_vowels (char* str)

{ char * p = str;

int cnt = 0;

if (str==NULL) return cnt;

while (*str != '\0') // test for null-terminator

{

switch (*str) // test for vowels

{

case 'a': case 'A':

case 'e': case 'E':

case 'i': case 'I':

case 'o': case 'O':

case 'u': case 'U':

str++; // str refers to a vowel, so ignore and advance to next character

cnt++; // increment the count

break;

default:

*p++ = *str++; // non-vowel -- copy the character and advance both pointers

break;

}

}

*p = '\0'; // ensure the modified string is null-terminated!

return cnt;

}

What are the uses of rtos?

* Enables real-time, deterministic scheduling and task prioritization

* Abstracts away the complexities of the processor

* Provides a solid infrastructure constructed of rules and policies

* Simplifies development and improves developer productivity

* Integrates and manages resources needed by communications stacks and middleware

* Optimizes use of system resources

* Improves product reliability, maintainability and quality

* Promotes product evolution and scaling

Write a program that would find the count of occurrence of largest digit in the input number?

#include
#include
void main()
{
long int n,r,m,max=0,count=0;
clrscr();
printf("Enter the Number:");
scanf("%ld",&n);
m=n;
while(n>0)
{
r=n%10;
if(r>max)
max=r;
n=n/10;
}
printf("\nLargest Digit is = %ld",max);
while(m>0)
{
r=m%10;
if(r==max)
count++;
m=m/10;
}
printf("\n\nOccurence of Largest Digit %ld is = %ld",max,count);
getch();
}

output:

Enter the Number:68596999

Largest Digit is = 9

Occurence of Largest Digit 9 is = 4

What is a Virtual PBX and what is the function of a Virtual PBX?

A virtual PBX is a phone exchange that serves a specific office or building, as opposed to one that a common carrier or telephone company operates for many businesses or for the general public.

How do you choose multiple if statement and switch statement?

If you must evaluate two or more expressions separately, use multiple if statements. If you only need to test all the possible evaluations of a single expression, use a switch.

Write a program to implement parity bit checker?

# include

# define bool int

/* Function to get parity of number n. It returns 1

if n has odd parity, and returns 0 if n has even

parity */

bool getParity(unsigned int n)

{

bool parity = 0;

while (n)

{

parity = !parity;

n = n & (n - 1);

}

return parity;

}

/* Driver program to test getParity() */

int main()

{

unsigned int n = 7;

printf("Parity of no %d = %s", n,

(getParity(n)? "odd": "even"));

getchar();

return 0;

}

CODING BY:SONU BARNWAL CENTRAL UNIVERSITY OF BIHAR

What is counted pretest loop?

While loop is counted as pretested loop.

How do you make a program of a game by using the C programming language?

Typically you won't use C to write games, particularly non-trivial games. C++ is the language of choice for most game developers.

Can you use a commit statement within a database trigger?

Yes, you can very definitely use transactions within a trigger in one of two common ways;

1. As with any other use of transactions - to ensure a collection of commands within the trigger are executed in a repeatable way in the event of failure.

2. To 'undo' the process that caused the trigger to fire. For example, the trigger might be doing some additional integrity checks and issuing a rollback to undo the initiating update/delete.

---------

AnswerCome to think of it, I have never seen a commit on triggers. Triggers as you know are a last line defense based on an action that was carried out by an insert,update or delete. Hence, since the trigger exists on the server, and is only fired if one of the above conditions are executed then it seems pointless to use a commit in the trigger. Also commit goes along nicely with transactions where you begin the transaction and if all is well then you issue a commit, else if the transaction fails, then you issue a rollback.

What are the main features of arrays. How are arrays used and created?

AnswerWhat is an array:

In programming languages, an array is a way of storing several items (such as integers). These items must have the same type (only integers, only strings, ...) because an array can't store different items. Every item in an array has a number so the programmer can get the item by using that number. This number is called the index. In some programming languages, the first item has index 0, the second item has index 1 and so on. But in some languages, the first item has index 1 (and then 2, 3, ...).