> Online tutorial : c tutorial
Showing posts with label c tutorial. Show all posts
Showing posts with label c tutorial. Show all posts

loops in c

data types in c

Primitive Types in c

Primitive Data Types

char
Holds any character
int
Integer type
short int
Integer no larger than int
long int
Integer no smaller than int
float
Floating point (real number)
long float
Double precision float
double
(ditto)
void
Holds no value, uses no storage (except as a pointer)

Character Utilities in c

Character Utilities

char ch;
isalpha(ch)
Is alphabetic a..z A..Z
isupper(ch)
Is upper case
islower(ch)
Is lower case
isdigit(ch)
Is in the range 0..9
isxdigit(ch)
Is 0..9 or a..f or A..F
isspace(ch)
Is white space character (space/newline/tab)
ispunct(ch)
Is punctuation or symbolic
isalnum(ch)
Is alphanumeric (alphavetic or number)
isprint(ch)
Is printable on the screen (and space)
isgraph(ch)
If the character is printable (not space)
iscntrl(ch)
Is a control character (not printable)
isascii(ch)
Is in the range 0..127
iscsym(ch)
Is a valid character for a C identifier
toupper(ch)
Converts character to upper case
tolower(ch)
Converts character to lower case
toascii(ch)
Converts character to ascii (masks off top bit)

operator in c


An operator is something which takes one or more values and does something useful with those values to produce a result. It operates on them. The terminology of operators is the following:
operator
Something which operates on someting.
operand
Each thing which is operated upon by an operator is called an operand.
operation
The action which was carried out upon the operands by the operator!






  • Comparisons and Logic Operator



  • Arithmetic Operators



  • Operators and Precedence



  • The Cast Operator



  • Special Assignment Operators ++ and --

  • format statement in c

    Formatting statement in c


    main() /* Main program starts here */
    {
    printf("Good form ");
    printf ("can aid in ");
    printf ("understanding a program.\n");
    printf("And bad form ");
    printf ("can make a program ");
    printf ("unreadable.\n");
    }

    1.It is an example of a well formatted program. Even though it is very short and therefore does very little, it is very easy to see at a glance what it does.
    2..Your C compiler ignores all extra spaces and all carriage returns giving you
    3.considerable freedom concerning how you format your program. Indenting and adding spaces is entirely up to you and is a matter of personal taste.





    adding comment in c

    Comments are added to make a program more readable to you but the compiler must ignore the
    comments.
    • The slash star combination is used in C for comment delimiters.
    • They are illustrated in the program at hand.
    • Please note that the program does not illustrate good commenting practice, but is intended to illustrate where comments can go in a program. It is a very sloppy looking program.  
    • The first slash star combination introduces the first comment and the star at the end of the first line terminates this comment.
    • Note that this comment is prior to the beginning of the program illustrating that a comment can precede the program itself.
    • Good programming practice would include a comment prior to the program with a short introductory description of the program.
    • The next comment is after the "main( )" program entry point and prior to the opening brace for
      the program code itself.

    Program
    /* This is a comment ignored by the compiler */
    main( )
     /* This is another comment ignored by the compiler */
    {
    printf("We are looking at how comments are ");
    /* A comment is
    allowed to be continued on another line */
     }
    /* One more comment for effect */

    Identifiers in c

    Identifiers is used for any variable, function, data definition, etc. In the programming language C,an identifier is a combination of alphanumeric characters, the first being a letter of the alphabet or an underline, and the remaining being any letter of the alphabet, any numeric digit,or the underline.

    Two rules must be kept in mind when naming identifiers.

    1. The case of alphabetic characters is significant. Using "INDEX" for a variable is notthe same as using "index" and neither of them is the same as using "InDex" for a variable. Allthree refer to different variables.

    2. As C is defined, up to eight significant characters can be used and will be considered significant. If more than eight are used, they may be ignored by the compiler. This may or may not be true of your compiler. You should check your reference manual to find out how many characters are significant for your compiler.



    program

    #include<stdio.h>
    #include <conio.h>
    void main()
    {
    int d;//d
    is identifier
    clrscr();
    printf("enter the value");
    scanf("%d",&d);
    getch();
    }