Thursday 31 August 2017

TOO MANY TYPES IN DECLARATION - ERRORS IN C PROGRAMMING

TOO MANY TYPES IN DECLARATION - ERROR IN C PROGRAMMING 

Compile Time Error

Too many types in declaration is a common error that occurs when we try to declare a function or variable of multiple types that is not allowed in C programming .As for example
int char a;
then this statement results in this type of error and exactly this situation is happening with the program in the above image. Here compiler gets confused that what is the exact data type of a;

In the above program in image, structure is defined that is a user defined data type thats why the compiler is condensed about the return type of main() function.Compiler is considering the structure as a data type so there are two data types there the first one is int and the second one is structure.And this ambiguity results in this error. And the second error is also explaining the same thing that incompatible types. So,when we put a semicolon before int and after the structure definition the error will be gone.
I hope you enjoyed this post...stay connected I will be posting  such interesting posts.

Other posts:
 how to insert image in C/C++ language
Introduction to Errors in C programming
C program for Bisection method

Wednesday 30 August 2017

INTRODUCTION TO ERRORS AND THEIR TYPES IN BRIEF

INTRODUCTION TO ERRORS AND THEIR TYPES IN BRIEF

While writing programs we have to take care of many things and whenever we miss any thing required this creates a situation that prevent the program execution.
In simple words any problem generated while developing a program is known as an Error.Technically errors are known as bugs in computer science.
Basically there are three types of errors in c programming:
Runtime Errors
Compile Errors
Logical Errors

C Runtime Errors

C runtime errors are those errors that occur during the execution of a c program and generally occur due to some illegal operation performed in the program. Examples of some illegal operations that may produce runtime errors are:

Dividing a number by zero
Trying to open a file which is not created
Lack of free memory space

It should be noted that occurrence of these errors may stop program execution, thus to encounter this, a program should be written such that it is able to handle such unexpected errors and rather than terminating unexpectedly, it should be able to continue operating. This ability of the program is known as robustness and the code used to make a program robust is known as guard code as it guards program from terminating abruptly due to occurrence of execution errors.

Compile Errors


Compile errors are those errors that occur at the time of compilation of the program. C compile errors may be further classified as:

Syntax Errors

When the rules of the c programming language are not followed, the compiler will show syntax errors. For example, consider the statement,
int a,b:
The above statement will produce syntax error as the statement is terminated with : rather than ;

Semantic Errors

Semantic errors are reported by the compiler when the statements written in the c program are not meaningful to the compiler. For example, consider the statement,
b+c=a;
In the above statement we are trying to assign value of a in the value obtained by summation of b and c which has no meaning in c. The correct statement will be
a=b+c;
Logical Errors

Logical errors are the errors in the output of the program. The presence of logical errors leads to undesired or incorrect output and are caused due to error in the logic applied in the program to produce the desired output. Also, logical errors could not be detected by the compiler, and thus, programmers has to check the entire coding of a C program line by line.

Tuesday 29 August 2017

C program for Bisection method

C program to implement bisection method in easy way..

bisection method theory

Here we have used a term tolerance value .Tolerance value is the difference between two consecutive

approximate roots of the equation that can be neglected.
As for example 1.00008 and 1.00004 are two approximate consecutive roots .

.One of them can be answer if there will be tolerance value of 0.00004 or greater otherwise not.
Here we have used a function fabs that returns the absolute double value and also takes double value 
as an argument.

 #include<conio.h>  
 #include<stdio.h>  
 #include<math.h>  
 float F(float x)  
 {  
   return x*x*x-x-1;  
 }  
 /*  
 f(0)=-ve  
 f(1)=-ve  here a=1 f(a)  
 f(2)=+ve  and b=2  
 tolerance value:0.0005  
 */  
 int main()  
 {  
   float a,b,c,d;  
   int i=0;  
   printf("Enter the interval(a,b) in which the roots of the equation lies::");  
   scanf("%f %f",&a,&b);  
   printf("\nEnter the tolerance value::");  
   scanf("%f",&d);  
   do{  
       c=(a+b)/2;  
       ++i;  
       if(F(a)*F(c)<0)//f(a)<0  
       {  b=c;  
         printf("\nValue of a and b in %d iteration is %f and %f",i,a,b);  
       }  
       else  
       {  
         a=c;  
         printf("\nValue of a and b in %d iteration is %f and %f",i,a,b);  
       }  
   }while(fabs(a-b)>d||F(c)==0);  
   printf("\nRoot is %f",c);  
   printf("\nPress any key to exit");  
   getche();  
   return 0;  
 }  
                                               


How to implement Facebook audience network banner ad in android app using Android Studio

Its very simple to implement Facebook audience network banner ad in android app using Android Studio. We will complete it in 4 Steps. 1. ...