What is a data type? Differentiate between array and pointer. Write a program to interchange
2 variables without using the third one.
What is a data type?
A data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. A string, for example, is a data type that is used to classify text and an integer is a data type used to classify whole numbers.
Differentiate between array and pointer.
An array is a collection of elements of similar data type whereas the pointer is a variable that stores the address of another variable.
Write a program to interchange 2 variables without using the third one.
#include <iostream>
int main(void) {
int a=1,b=2,c;
c=a;
a=b;
b=c;
cout << a << endl;
cout << b << endl;
}
Comments
Leave a comment