Thursday, July 26, 2012

Some Important Concepts Of C/C++ Language

Hello friends today i am telling you some important points related to C /C++ Language.These points really help you,when you do programming.I am fully sure after read this article you will get some extra knowledge about C/C++ Language,so don't waste your time and read the following points.


http://www.learning-tutorials.blogspot.com




1)The difference between union and structure is that Structure used as prototype in creating objects with same memory, it can not compress the memory.

struct a
{
   int a;
   float b;
}obj;

Here obj is having 6 bytes in memory.

Where as for union, it allocates largest memory among all datatypes defined in the union.

union a
{
     int a;
     float b;
}obj;

Here obj is having 4 bytes instead of 6 Bytes.


So, union utilizes largest memory assigned to variable among all variables and it will be used for all its operations.




2)int bit1:1; --> 'int' indicates that it is a SIGNED integer.
For signed integers the leftmost bit will be taken for +/- sign.


3)In Enum,Unless a value is assigned, the elements are given a default integer value which is an increment of the previous one.


4)enum takes the sequentials values by default after assigning a particular number.


5)Scanf family functions support Scanset specifiers which are represented by %[]. Inside scanset, we can specify single character or range of characters. While processing scanset, scanf will process only those characters which are part of scanset. We can define scanset by putting characters inside squre brackets.Scansets are case-sensitive.

For example:


#include<stdio.h>
#include<conio.h>
int main()
{

        char str[50];
        clrscr();
        printf("\n Please enter your name:");
        scanf("%[A-Z]s",str);

        printf("\n Name is:");
        puts(str);

getch();
return(0);
}
output:

   Please enter your name:LOGic
   
    Name is:LOG



6)If first character of scanset is ‘^’, then the specifier will stop reading after first occurence of that character. For example, given below scanset will read all characters but stops after first occurence of ‘o’
 

scanf("%[^o]s", str);


7)Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security.


8)printf returns the no. of chars that was printed(included all escape sequences).


9)If both base and derived classes are caught as exceptions then catch block of derived class must appear before the base class.

10)We cannot predict the value of volatile variable because its value can be changed by any microprocessor interrupt.


11)In c char is integral data type. It stores the ASCII value of any character constant.

12)Any expression which is evaluated inside the sizeof operator its scope always will be within the sizeof operator.


13)Signed is higher data type than unsigned int.


14)Syntax of enum data type is:

enum  [<tag_name>]{

    <enum_constanat_name> [=<integer_ value>],

    …

} [<var_name>,…]
 


Note:

[] : Represents optional .

<>: Represents any valid c identifier



15)Size of int is always equal to word length of micro preprocessor in which your compiler has based.


16)Nesting of enum constant is not possible in c.


17)Enum is primitive data type.


18)we cannot specify two storage class auto and register in the declaration of any variable.


19)we cannot use signed or unsigned modifiers with float data type. In c float data type by default signed and it cannot be unsigned.


20)Turbo c is based on 8086 microprocessor which word size is two byte.

21)Nesting of structure is possible i.e. we can declare a structure within another structure but it is necessary inner structure must declares structure variable otherwise we cannot access the data member of inner structure.


22)Array, union, structure can be member of a structure (not same structure).




Also see this:

             My Full Programming Tutorial





                     ***Thanks Friends***

No comments:

Post a Comment

Please Give Me Your Views

Popular Posts