What are the different types of errors in C and when they occur?
Answers were Sorted based on User's Feedback
Answer / pavan_mustyala
1. Syntax Errors: Error found during compilation e.g.
missing semi colon, missing comma, undeclared identifier,
etc
2. Semantic Errors: Logical error in the program due to
which functionality behaves differently than expected.
3. Runtime Errors: Exceptions due to insufficient memory
and Segmentation fault, stack over flow, etc.
Is This Answer Correct ? | 70 Yes | 12 No |
Answer / sivavendra
compilation errors(occurs during compilation) and runtime errors(occurs during runtime)...
Is This Answer Correct ? | 27 Yes | 9 No |
Answer / vishwjeet singh
PROTOTYPE ERROR:when any header file is missing then we error hat was shown by compilling the program is prototype error.
SYNTEX ERROR: Actually these type of errors occured when
programmer misses the syntax.(Syntsx: (,),(.),(;),("") etc.)
Example:- printf("your sum is %d"c);
This may occure error "Syntax error".
Right Syntax is:printf("your sum is %d",c);
SYSTEMATIC ERROR:These type of errors occure when there is a
missmatch of functionallity.
Example: int sum is;
this may occure error because while declaring a variable c
is not allowed space( ).
Right Syntax is: int sum_is;
RUNTIME ERROR: Thes etype of errors also known as "linker
errors".These type of errors occure after compilation.This
will not give you the line where these type of errors occured.
Is This Answer Correct ? | 22 Yes | 4 No |
Answer / sudhir seth
Syntax errors: Actually these type of errors occured when
programmer misses the syntax.(Syntsx: (,),(.),(;),("") etc.)
Example:- printf("your sum is %d"c);
This may occure error "Syntax error".
Right Syntax is:printf("your sum is %d",c);
Symmentic errors:These type of errors occure when there is a
missmatch of functionallity.
Example: int sum is;
this may occure error because while declaring a variable c
is not allowed space( ).
Right Syntax is: int sum_is;
Runtime errors: Thes etype of errors also known as "linker
errors".These type of errors occure after compilation.This
will not give you the line where these type of errors occured.
Is This Answer Correct ? | 22 Yes | 9 No |
How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?
Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.
#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }
char* f() return "hello:"; void main() {char *str=f(); }
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
how tally is useful?
Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly
write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;
#include<iostream.h> #include<stdlib.h> static int n=0; class account { int age,accno; float amt; char name[20]; public: friend void accinfo(account [] ,int); void create(); void balenq(); void deposite(); void withdrawal(); void transaction(account []); }; void account :: create() { static int acc=1231; accno=acc+n; cout<<"\n\tENTER THE CUSTOMER NAME : "; cin>>name; cout<<"\n\t ENTER THE AGE : "; cin>>age; cout<<"\n\t ENTER THE AMOUNT : "; cin>>amt; // if(amt<=500) // cout<<"\n\tAMOUNT IS NOT SUFFICIENT TO CREATE AN ACCOUNT..."; cout<<"\n\t YOUR ACCOUNT NUMBER : "<<accno<<endl; n++; } void accinfo(account cus[],int ch) { int no,flag=0; cout<<"\n\t\tENTER YOUR ACCOUNT NUMBER : "; cin>>no; for(int i=0;i<=n&&flag==0;i++) if(no==cus[i].accno) { flag=1; switch(ch) { case 2: cus[i].balenq(); break; case 3: cus[i].deposite(); break; case 4: cus[i].withdrawal(); break; case 5: cus[i].transaction(cus); break; default: cout<<"\n\t\tEND OF THE OPERATION"; exit(1); } } if(flag==0) cout<<"\n\t\tYOUR ACCOUNT DOES NOT EXIST..."<<endl; } void account :: balenq() { cout<<"\n\t\tCUSTOMER NAME : "<< name << endl; cout<<"\n\t\tBALANCE : "<< amt << endl; } void account :: deposite() { int damt; cout<<"\n\t\tCUSTOMER NAME : "<< name <<endl; cout<<"\n\t\tBALANCE : "<< amt <<endl; cout<<"\n\tENTER THE AMOUNT TO BE DEPOSITED : "; cin>>damt; amt+=damt; cout<<"\n\t\tYOUR CURRENT BALANCE : "<<amt<<endl; } void account :: withdrawal() { int wamt; cout<<"\n\t\tCUSTOMER NAME : "<< name; cout<<"\n\t\tBALANCE : "<< amt; cout<<"\n\tENTER THE AMOUNT TO BE WITHDRAWN : "; cin>>wamt; if(amt-wamt>=500) { amt-=wamt; cout<<"\n\t\tYOUR CURRENT BALANCE : "<<amt; } else cout<<"\n\tYOUR BALANCE IS TOO LOW FOR WITHDRAWAL..."<<endl; } void account :: transaction (account cus[]) { int no,tamt,flag=0; cout<<"\n\tENTER THE RECEIVER'S ACCOUNT NUMBER : "; cin>>no; cout<<"\n\t\t ENTER THE AMOUNT : "; cin>>tamt; for(int i=0;i<=n&&flag==0;i++) if(cus[i].accno==no) { flag=1; cus[i].amt+=tamt; amt-=tamt; cout<<"\n\t\tYOUR CURRENT BALANCE : "<<amt<<endl; cout<<"\n\t\t RECEIVER'S BALANCE : "<<cus[i].amt<<endl; } if(flag==0) cout<<"\n\tRECEIVER'S ACCOUNT NUMBER IS NOT AVALIABLE..."<<endl; } void main() { account cus[10]; int ch; do { cout<<"\n\t\t BANK ACCOUNT"; cout<<"\n\t\t ************\n"; cout<<"\n\t\t1.CREATE AN ACCOUNT"; cout<<"\n\t\t2.BALANCE ENQUIRY"; cout<<"\n\t\t3.DEPOSITE"; cout<<"\n\t\t4.WITHDRAWAL"; cout<<"\n\t\t5.TRANSACTION"; cout<<"\n\t\t6.EXIT\n\n"; cout<<"\n\t\tENTER YOUR CHOICE : "; cin>>ch; if(ch==1) cus[n].create(); else accinfo(cus,ch); }while(1); }
void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....
void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..
32 Answers College School Exams Tests, CTS, HCL, iGate, SmartData,
difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?