C Programming and Computer Geeks: C Tutorials

Search MY Blog

Showing posts with label C Tutorials. Show all posts
Showing posts with label C Tutorials. Show all posts

Thursday 5 December 2013

C Header Files and its supported functionalities


<stdio.h>: input /output functional operations in program.

<conio.h>: to clear screen and pause information function.

<ctype.h>: functions for testing characters.

<string.h>: functions for manipulating string.

<math.h>: mathematical  functionalities.

<stdlib.h>: utility function for number, conversion and storage allocation.

<assert.h>: functions that can be used to add diagnostics to a program.

<stdarg.h>: functions that can be used to step through a list of function arguments.

<setjmp.h>: functions that can be used to avoid the normal call and return sequence.

<signal.h>: functions for handling exceptional condition that may arise in a program.

<time.h>: functions for manipulating date and time.

<limits.h>: constant definitions for the size of C data types.

<float.h>: definitions relating to floating-point arithmetic.


Click here for more C Tutorials and Concepts.

 

Sunday 1 December 2013

Understanding Pointers in C/C++

When we declare a variable in C/C++ etc.. like int x or int y , it tells the compiler to reserve the space of two bytes(Size depends on OS Platforms/Compilers ) in the memory to store the integer type value and identify the storage location in the memory by 'x' or 'y' etc.
So every variable has three properties 1. Identifier (Name like x or y) 2. Value(x=10 or y=15 etc.) 3. Its address (hexadecimal) in the Temporary Memory i.e. RAM. Since compiler makes our job simpler by giving an opportunity to know only the variable’s name and its value then in normal situation we have no need to worry about the location or address of the variable. But in advanced programming and certain types of problems we have to handle and use the address of variables. So the concept of Pointers solves this problem. 
We can say Pointer Definition as "Pointers are those variables which holds the address of another variable”. In C/C++ we can see the “Address” or “Memory Location Number” of any variable by using "&" i.e. if we declare a variable 'x' eg: int x; we can see its address by printf statement as follows printf("\n %d", &x);
Now to handle the address of variables we have the facility to declare the Pointer variable like this int *p; this statement tells the compilers to reserve the space in memory to store the address of integer type variable. To assign the address of any integer type variable to 'p' we have to write the statement like p = &x; 

Example Program:

Understanding Pointers in C
Pointers in C



void main()
{
 int x = 34; //variable declaration and definition.
 int *p; //pointer declaration.

 /* p is a pointer which points to a integer variable or ‘p’   is  a pointer which holds the address of an integer variable..  */
 p = &x; //Assigning the address of variable x to pointer ‘p’.
 printf("Address of variable x is : %x",p);//prints the  address  of variable x. here %x displays Address in Hexa  decimal format.
}

Clickhere for more C Tutorials and Concepts.



Thursday 28 November 2013

What getchar function returns and list out similar functions?



what is the Output of the following Program?

#include “stdio.h”
void main(void)
{
printf("\t %d ",getche());
getch();
}

ANSWER:  it will return the Equivalent ASCII decimal value of entered character..


getchar, getch, getche functions
getchar() Function

 
getch(), getche(), getchar() will return integer value.

getchar() returns the Equivalent decimal(ASCII) value of entered character with echoing the entered character.

getche() returns the Equivalent decimal(ASCII) value of entered character with echoing the entered character.

getch() returns the Equivalent decimal(ASCII) value of entered character without echoing the entered character.

Note: Here getchar() is ASCII C Standard Function. getche() and getch() functions are non-standard functions. so this program may not be compiled successfully in many Platforms.. This can be compiled
successfully in VC++ and Turbo C/C++ compilers...

Click here for more C Faq



Search This Blog