Answer to Question #274807 in C for Amu Raj

Question #274807

What is a data type? Differentiate between array and pointer. Write a program to interchange

       2 variables without using the third one.         


1
Expert's answer
2021-12-03T14:34:12-0500

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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS