What computer programming language is used to program robots?
Robotics programming is usually done in C or a derivative of C, although it's entirely possible for other languages to be used. For example, "RobotC" is a common language used for various micro-controllers, however it's now possible to use Java as well with Sparkfun's "IOIO" microcontroller.
Write a program that ask the user to enter a number n and display the first n even numbers?
#include "stdio.h" int main() { unsigned int number, count; printf("Enter the Number \t"); scanf("%d", &number); printf("The even numbers are: \n"); for(count = 0x01; (count < number && number!= 0x00)) { if(count%2) { }else { printf("%d\n", count); } count++; } return 0; }
What kind of data do you put in arrays?
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
What is the main function of a cumputer?
The six basic computer operations, as pertaining to a pseudocode algorithm, are:
1. A computer can receive information.
2. A computer can put out information.
3. A computer can perform arithmetic.
4. A computer can assign a value to a variable or memory location.
5. A computer can compare two variables and select one of two alternative actions.
6. A computer can repeat a group of actions.
For more information, please refer to the related link that I added below.
Why is the purpose of header files in c programming?
Header files allow programmers to separate interfaces from implementations. Typically, a header file contains the declaration of a single class or a group of related classes or functions, or both. The definitions are typically placed in a corresponding source file (which must include the header), although inline functions are often defined in the header itself, while incomplete types such as template classes and template functions must always be defined in the header.
Although you could place all your code in a single file, header files make it easier to re-use common functions and classes from other programs. You can also build libraries of common classes and functions, each of which requires a header (the interface) that must be included in your source in order for your programs to be able to link to those libraries. Thus headers are an aid to modularisation and re-usability, thereby reducing the need to write duplicate code.
Define function with advantages and disadvantages in C programming?
Write a c program to check whether a no is prime or not?
#include<stdio.h> #include<conio.h> int i=1, count=0,n; clrscr(); printf("Enter Any Number"); scanf("%d", &n); while(i<n) if(n%i==0) { count++; i++; } if(count==2) printf("Given Number is Prime"); else printf("Given Number is not Prime"); getch(); }
How input device transfers data to the CPU?
Every input device attached to the motherboard bus lines has a direct line of communication with the CPU. These lines are known as interrupt request lines (IRQs) which can be prioritised. By signalling the CPU that an input is pending, the CPU can alert the operating system to deal with the request, which will then be prioritised accordingly.
What is a two dimensional array in c?
its simple
just do this swappping
for(i=0;i<m;i++) /*A*/
for(j=0;j<i;j++) /*B*/
{
x=a[i][j];
a[i][j]=a[j][i];
a[j][i]=x;
}
I think A and B need a change :
/*Permutation : */
for ( i = 0 ; i <= lig ; i++ ) /*A*/
for ( j = 0 ; j <= i ; j++ ) /*B*/
{
int permut = MatA[i][j] ;
MatA[i][j] = MatA[j][i] ;
MatA[j][i] = permut ;
}
/*End of permutation */
printf("\nDISPLAY MATRIX : \n") ;
for ( i = 0 ; i < col ; i++ )
{
for ( j = 0 ; j < lig ; j++ )
{
printf("%d", MatA[i][j]) ;
}
printf("\n") ;
}
A simple array has of basic data type such as char, int, float... arrays of structure has the type of structure.
struct student std[12];
Here std is an arrays of structure.
Difference between internal and external sorting?
Internal sorting
it means we are arranging the number within the array only which is in computer primary memory.
External sorting
it is the sorting of numbers from the external file by reading it from secondary memory.
Why is the JVM platform dependent?
That depends on how you look at it. The point of the JVM is to allow Java bytecode to be executed on any platform, regardless of what machine it was compiled on.
The actual implementation of the JVM, however, must be platform-specific.
What is a finite and infinite set?
A set which containing $and pi are the end blocks are the finite and without these are infinite
Why are pointers needed in C programming?
pointer is used when we want to retain the change in values between the function calls.
Similarly double pointer is used when we want to retain the change in pointers between the function calls. If you want to modify pointers than you need double pointer to retain the change.
What do you call the loop that never ends?
That kind of loop is referred to as an Infinite Loop. It occurs when the exit conditions can never be met or when the programmer fails to supply an exit.
For example:
Do while (1>0)
(that will loop forever because 1 is always greater than 0)
for (int i = 0; i < myArray.length(); i++) System.out.println(myArray[i]);
What are the effectiveness of algorithm?
-space
•Benchmarking: implement algorithm,
-run with some specific input and measure time taken
-better for comparing performance of processors than for comparing performance of algorithms
•Big Oh (asymptotic analysis)
-associates n, the problem size,
-with t, the processing time required to solve the problem
Matrix addition using 2-D array in turbo c?
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a[100][100]={0}; /* initializing matrices to '0' */
int b[100][100]={0};
int c[100][100]={0}; /*matrix-c for multiplication*/
/*r1,c1 are rows and coloumns for matrix-a.r2,c2 for matrix-b.*/
int r1,c1,r2,c2;
int i,j,k;
clrscr();
printf("enter the no of ROWS and COLOUMNS for MATRIX-A\n");
scanf("%d %d",&r1,&c1);
printf("enter the no of ROWS and COLOUMNS for MATRIX-B\n");
scanf("%d %d",&r2,&c2);
if(c1==r2)
{
printf("matrix multiplication possible\n\nenter numbers in MATRIX-A\n");
/* to enter numbers in matrix-a*/
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
scanf("%d",&a[i][j]);
printf("enter numbers in MATRIX-B\n");
/* to enter numbers in matrix-b*/
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
scanf("%d",&b[i][j]);
/*for matrices multiplication*/
for(i=0;i<r1;i++)
for(j=0;j<c2;j++)
for(k=0;k<c1;k++)
*(*(c+i)+j)+=*(*(a+i)+j)*(*(*(b+k)+j));
printf("result of multiplication of matrices is \n");
/*to display as matrix format*/
for(i=0;j<r1;i++)
{
printf("\n");
for(j=0;j<c2;j++)
printf("%d\t",*(*(c+i)+j));
}
} //if
else
printf("MATRIX multiplication not Possible\n");
getch();
return 0;
}
/* TWINKLING TWINS */
Write a program to count the length of a string without using built in functions?
In JavaScript: To find the length of the string we you length method.
__
__
__
Click the button to return the number of characters in the string "Hello World!".
click here
__
__
function myFunction() {
var str = "Hello World!";
var n = str.length;
document.getElementById("demo").innerHTML = n;
}
__
__
__
Hope this helps. Thank you
The do while loop is useful for the special loops that they must circulate at least one time.
#include <iostream>
using namespace std;
int main()
{
int num,digit;
cout<<"Enter a #\n";
cin>>num;
cout<<"Invers is : ";
do
{
digit=num/10;
cout<<digit;
num/=10;
} while(num != 0);
return 0;
}
What is sorting in C language?
Quicksort in any programming language is an algorithm for sorting data sequences. It is typically implemented as follows (example demonstrates a quicksort of an array of type int). Note that a half-open range, [begin:end), includes the one-past-the-end of the range and is the conventional means of defining a range of contiguous array values. When begin==end, the range is deemed empty.
// forward declarations
void qsort (int* unsigned); // this is the function you will actually invoke
void qsort_rec (int*, int*); // recursive function
int* partition (int*, int*); // utility functions...
int* select_pivot (int*, int*);
void swap (int*, int*);
int count (int*, int*);
// sort a data sequence of length size
void qsort (int* data, unsigned size) {
qsort_rec (data, data + size);
}
// recursively sort the half-open range [begin:end)
void qsort_rec (int* begin, int* end) {
if (count (begin, end) < 2) return; // end point of recursion
int* pivot = partition (begin, end);
qsort_rec (begin, pivot);
qsort_rec (++pivot, end);
}
// divide the half-open range [begin:end) into two around a pivot value
int* partition (int* begin, int* end) {
if (count (begin, end) < 2) return begin;
int* pivot = select_pivot (begin, end);
swap (begin, pivot);
--end;
while (begin != end) {
while (*(begin) <= *pivot && begin != end) ++begin;
while (*pivot < *(end) && begin != end) --end;
if (begin!=end) swap (begin, end);
}
assert (begin==end); // sanity check!
swap (pivot, begin);
return begin;
}
// select the median of three from a half-open range [begin:end)
int* select_pivot (int* begin, int* end) {
int* mid = begin + (count (begin, end) / 2);
if (*end<*begin) swap (begin, end);
if (*mid<*begin) swap (begin, mid);
if (*end<*mid) swap (mid, end);
return end;
}
// swap the values referred to by p and q
void swap (int* p, int* q) {
if (!p !q) return; // sanity check!
int t = *p;
*p = *q;
*q = t;
}
// count the elements in the half-closed range [begin:end)
int count (int* begin, int* end) {
int cnt = 0;
int add;
if (begin>end) { // swap pointers if the range is reversed
int* t = begin;
begin = end;
end = t;
add = -1; // count will be negative
} else {
add = 1; // count will be positive
}
while (begin++!=end) cnt+=add;
return cnt;
}
How do you declare a pointer to a structure in C?
It depends on whether you've declared a type alias or not. Without an alias, you must include the struct keyword:
struct record {
// ...
};
struct record* ptr; // declare a pointer to struct record
With an alias, the struct keyword can be omitted from the type name. By convention, we use the _t suffix to denote the type name. Typically, aliases are declared as part of the type declaration:
typedef struct record_t { // type name
// ...
} record; // alias
record* p; // declare a pointer to record
Note that record is the alias while struct record_t is the data type associated with that alias. We can use the type or the alias as we see fit, however type aliases are more convenient.
We can also declare pointer aliases in the type declaration:
typedef struct record_t {
// ...
} record, *record_ptr;
record_ptr p; // declare a pointer to record
However, this latter technique is best avoided because we can often end up inadvertently declaring pointer to pointer types instead of pointers:
record_ptr* p; // equivalent to: record** p; -- possibly erroneous
Note that you cannot use a type alias within a self-referential data type, such as a node with embedded pointers to other nodes (as used in linked list implementations):
typedef struct node_t {
int data;
node* next; // error: node is not (yet) defined
node* prev; // error: node is not (yet) defined
} node;
To fix these errors, use the actual type name:
typedef struct node_t {
int data;
struct node_t* next;
struct node_t* prev;
} node;
What are the characteristics of a structured program?
A structured program is not OO, yet still exhibits low coupling and high cohesion.