Q.what is token?
Ans:- It is basically smallest unit of programs .It is main building block of any programming language.
Various types of tokens used in c++ are : -
a. Keywords
b. Identifiers
c. Literals
d. Punctuators
e. Operators
Q.what is identifiers?
Ans- All the words used in c/c++ program i.e.names of variables,functions,labels,and various other user defined objects except the keywords are called identifiers.
Rules for identifiers:-
1. It should not be any keywords/
2. The first character must be a letter or an underscore, and subsequent characters must be either letter,digits or underscore.
3. The identifiers should not have the same name as functions that are in c/c++ library.
Here are some correct and incorrect identifiers-
Correct Incorrect
Count 1count
Test23 hi!there
High_balance high….balance, high balance
Q.difference between function signature and function prototype?
Ans.
* Function signature -
*Function Prototype -
Void function(int,char,double,float) ;
The highlitted syntax is function signature.
While the whole syntax is function prototype or declaration.
Q.Difference between actual and formal argument?
Ans.
-> When we pass the arguments at the time of invoking(calling) the function,then the argument is known as actual argument.
->The arguments declared inside the function definition is known as formal arguments.
Consider a Example-
#include<iostream>
Using namespace std;
Void add(int x,int y)
{
Cout<<x+y<<endl;
}
Int main()
{
int i=5,j=6;
add(i,j);
Return 0;
}
In the above example i and j is the actual argument.
And x and y is formal arguments.
->When we call by value-The value of the actual arguments is passed and copied to the formal arguments.
2. Protected:-
3.Public :-
Ans:- It is basically smallest unit of programs .It is main building block of any programming language.
Various types of tokens used in c++ are : -
a. Keywords
b. Identifiers
c. Literals
d. Punctuators
e. Operators
Q.what is identifiers?
Ans- All the words used in c/c++ program i.e.names of variables,functions,labels,and various other user defined objects except the keywords are called identifiers.
Rules for identifiers:-
1. It should not be any keywords/
2. The first character must be a letter or an underscore, and subsequent characters must be either letter,digits or underscore.
3. The identifiers should not have the same name as functions that are in c/c++ library.
Here are some correct and incorrect identifiers-
Correct Incorrect
Count 1count
Test23 hi!there
High_balance high….balance, high balance
Q.difference between function signature and function prototype?
Ans.
* Function signature -
- The function name along with their arguments list and their data types is known as function signature.
- It is a part of function prototype that the compiler uses to perform overloaded resolution (i.e function overloading )
*Function Prototype -
- The function prototype is even known as function declaration.
- The function prototype contains function name ,return type ,all argument list and their data types and ended by a semicolon.
Void function(int,char,double,float) ;
The highlitted syntax is function signature.
While the whole syntax is function prototype or declaration.
Q.Difference between actual and formal argument?
Ans.
->The arguments declared inside the function definition is known as formal arguments.
Consider a Example-
#include<iostream>
Using namespace std;
Void add(int x,int y)
{
Cout<<x+y<<endl;
}
Int main()
{
int i=5,j=6;
add(i,j);
Return 0;
}
In the above example i and j is the actual argument.
And x and y is formal arguments.
->When we call by value-The value of the actual arguments is passed and copied to the formal arguments.
->When we call by reference or address- The address of the actual argument is copied to the formal arguments.
Q. Different access modifiers in c++?
Ans.
C++ supports 3 access modifiers.
1.private
2.protected
3.public
1.Private:-
Q. Different access modifiers in c++?
Ans.
C++ supports 3 access modifiers.
1.private
2.protected
3.public
1.Private:-
- The members declared inside the private0 access modifiers can not be accessed directly by the object of a class.
- The private member or functions can be used only by the object of class through public member function of class.
- The private member can not be inherited in any way.
- defaultly the members declared inside the class is private.
2. Protected:-
- The members declared inside the protected access modifiers can not be accessed directly by the object of a class.
- The protected member or functions can be used only by the object of class through public member function of class.
- The private member can be inherited.(only this features makes it different from private access modifiers).
3.Public :-
- The public member can be accessed outside the class directly by the object of a class.
- It is the lowest level of security.