Posts

C MCQ with Answers

                                          C MCQ with Answers 1. What will be the output of the following C code? #include <stdio.h> int main ( ) { char * p = NULL ; char * q = 0 ; if ( p ) printf ( " p " ) ; else printf ( "nullp" ) ; if ( q ) printf ( "q \n " ) ; else printf ( " nullq \n " ) ; } a) nullp nullq b) Depends on the compiler c) x nullq where x can be p or nullp depending on the value of NULL d) p q Answer: a 2. Comment on the following C statement. const int *ptr; a) You cannot change the value pointed by ptr b) You cannot change the pointer ptr itself c) You May or maynot change the value pointed by ptr d) You can change the pointer as well as the value pointed by it Answer:...

First C Program and its Structure

First C Program and its Structure Lets see how to write a simple and most basic C program: #include < stdio . h > int main ( ) { printf ( "Hello,World" ) ; //single line comment return 0 ; /* multi line comments /* } Hello,World Different parts of C program Pre-processor Header file Function Variables Statements & expressions Comments All these are essential parts of a C language program. Pre-processor #include  is the first word of any C program. It is also known as a  pre-processor . The task of a pre-processor is to initialize the environment of the program, i.e to link the program with the header files required. So, when we say  #include <stdio.h> , it is to inform the compiler to include the  stdio.h  header file to the program before executing it. Header file A Header file is a collection of built-in(readymade) functions, which we can directly use in our program. Header files cont...

What are Keywords in C?

What are Keywords in C? Keywords are preserved words that have special meaning in C language. The meaning of C language keywords has already been described to the C compiler. These meaning cannot be changed. Thus, keywords cannot be used as variable names because that would try to change the existing meaning of the keyword, which is not allowed.(Don't worry if you do not know what variables are, you will soon understand.) There are total 32 keywords in C language. auto double int struct break else long switch case enum register typedef const extern return union char float short unsigned continue for signed volatile default goto sizeof void do if static while What are Identifiers? In C language identifiers are the names given to variables, constants, functions and user-define data. These identifier are defined against a set of rules. Rules for an Identifier An Identifier can only have alphanumeric characters(a-z , A-Z , 0-9) and underscore( _ ). The fir...