Thursday, 26 December 2013

Trap #1 :Error: Illegal Use Of Floating Point

There are  times when we write codes according to problem statement, Run it, and never be able to debug it.
Error: Illegal Use Of Floating Point is one such error. The problem is with the % operator you have used.

We all use '%' operator known as modulus operator in C. Lets focus on some facts about it :
  1. % operator gives Remainder of Division of the two numbers.
    Ex. 20 % 3 = 2
  2. On focusing a bit it will be clear that % operator gives its value in an int form.
  3. Hence its defined only for integer type variables. The above error occurs because you ave used % with a float type variable or constant.Ex #1:
    #include<stdio.h>
    main()
    {
    int a=20,b=3,c; //NO ERROR
    c=a%b;
    printf("%d",c);
    }
    ####No Error Output = 2

    Ex #2:
    #include<stdio.h>
    main()
    {
    float a=20,b=3,c;
    c=a%b;
    printf("%f",c);
    }
    ###Error illegal use of floating point
  4. If you want to use it with float values only then there is a solution for it too:
    use of fmod() Function defined under <math.h> library.

Wednesday, 25 December 2013

Meaning, Introduction & the Target Of This Blog

Hello Friends

We are all well aware that there are many web material (may be written by experts) on C.
Here This Blog is a quite different as I am too a 'Beginner' and  a 'Learner' .

There is a lot of difference when you write programs while learning (Programming Exercise Of Books) and when you create a 'Real World Program' starting from scraps or a mere IDEA. Things in real world almost rarely work in beginners case.
Here we will be dealing with all those common Mistakes or Exceptions of C and also a discuss Tips on a effective programming.

And last and the least the most interesting part of the blog will be I will be teaching you to create many interesting projects which will include real life Implementation and also we will learn to write few VIRUSES.
Please feel free to ask anything.