C C++ Errors Interview Preparation Guide
Refine your C C++ Errors interview skills with our 13 critical questions. These questions will test your expertise and readiness for any C C++ Errors interview scenario. Ideal for candidates of all levels, this collection is a must-have for your study plan. Download the free PDF now to get all 13 questions and ensure youre well-prepared for your C C++ Errors interview. This resource is perfect for in-depth preparation and boosting your confidence.13 C C++ Errors Questions and Answers:
1 :: Explain difference between c/c++ programing language?
what is necessity of c++ when existing c programing language?
The main reason is lengthy C programs lose "Global View" and
become very difficult to visualize as a single concept.
C++ is an advance than C lang which has more features...
But comparing efficiency C is more efficient than C++
But C++ has more flexibility than C.
Also C++ is both combination of OOP and OBP concepts.
C++ has more features as
1.Object oriented
2.Information hiding
3.Standard Template Library
4.Inheritance
5.Constructors & Destructors
6.Exception Handling
7.Overloading
become very difficult to visualize as a single concept.
C++ is an advance than C lang which has more features...
But comparing efficiency C is more efficient than C++
But C++ has more flexibility than C.
Also C++ is both combination of OOP and OBP concepts.
C++ has more features as
1.Object oriented
2.Information hiding
3.Standard Template Library
4.Inheritance
5.Constructors & Destructors
6.Exception Handling
7.Overloading
2 :: Can you explain exceptions?
An exception is an event, which occurs during the execution
of a program, that disrupts the normal flow of the program's
instructions.
of a program, that disrupts the normal flow of the program's
instructions.
3 :: When i use cout or cin call & then either << or >> .....it shows
declaration syntax error...what should i do?
cout<<"anything";
int a;
cin>>a;
return 0;?
If you are using Turbo C complier need to add #include<iostream.h> header file.
and If you are using Visual Studio then you need to add
#include<iostream>
using std namespace;
the above two statements.
and If you are using Visual Studio then you need to add
#include<iostream>
using std namespace;
the above two statements.
4 :: char* f()
return "hello:";
void main()
{char *str=f();
}
str will be a pointer to "hello:"
so on printing str will output hello:
so on printing str will output hello:
5 :: What is run time error?
An error that occurs during the execution of a program. In
contrast, compile-time errors occur while a program is
being compiled. Runtime errors indicate bugs in the program
or problems that the designers had anticipated but could do
nothing about. For example, running out of memory will
often cause a runtime error.
A runtime error is a computer error that appears in
the form of a message box consisting of a particular code
along with its corresponding definitions. Usually, a user
will notice that the computer becomes noticeably slow
before a runtime error appears.
After the runtime error message has been displayed and
closed, the software that shows this error would normally
close or freeze. In some cases, the operating system will
reboot.
contrast, compile-time errors occur while a program is
being compiled. Runtime errors indicate bugs in the program
or problems that the designers had anticipated but could do
nothing about. For example, running out of memory will
often cause a runtime error.
A runtime error is a computer error that appears in
the form of a message box consisting of a particular code
along with its corresponding definitions. Usually, a user
will notice that the computer becomes noticeably slow
before a runtime error appears.
After the runtime error message has been displayed and
closed, the software that shows this error would normally
close or freeze. In some cases, the operating system will
reboot.
6 :: void main()
{
int i=7;
printf("N= %*d",i,i);
}
Its output would be 7,
"%*d"
here * symbol doesn't affect of operation of %d.
so 7 is set to value in variable i.
"%*d"
here * symbol doesn't affect of operation of %d.
so 7 is set to value in variable i.
7 :: 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?
here in first statement
printf("%d",++i + --z + i++ + --i * ++y);
argument is : ++i + --z + i++ + --i * ++y.
first it will maintain stack operation like
++y (now fifth, it will execute and, y=4)(top 4)
--i (now fourth, it will execute and, i=6)
(because, last value of i were 7, once i++ were
executed, now --i will less one value in i)(top 3)
i++ (now third, it will execute and, i=6, it will
as it is, its value will for next stack value.)
(top 2)
--z (now second, it will execute and, z=1)(top 1)
++i (first it will execute and, i=6)(top 0)
now (++i + --z + i++ + --i * ++y)
(6+1+6+6*4)=(37)
it is output, say 37,for this printf("%d",++i + --z + i++
+ --i * ++y);
.................................................
Now Let me go with second statement, that is :
ans=++i + --z + i++ + --i * ++y;
here,
first of all ++y will contain the value of variable y=4
++y=4
after this, --i will less the value of variable i, say now
i = 4,
(--i=4),
after this, i++ will execute and, it will not increase the
value of variable i, right now, so value of i, say now i =
4, as it is.
after this, --z will less the value of variable z, say now
z = 1,
(--z=1)
now, ++i will increase the value of variable i.
Say i = 5.
.......................................................
now value of valiable i in memory is 5.
ans=5+1+5+5*4
ans=5+1+5+20
ans=31..........,
printf("%d",++i + --z + i++ + --i * ++y);
argument is : ++i + --z + i++ + --i * ++y.
first it will maintain stack operation like
++y (now fifth, it will execute and, y=4)(top 4)
--i (now fourth, it will execute and, i=6)
(because, last value of i were 7, once i++ were
executed, now --i will less one value in i)(top 3)
i++ (now third, it will execute and, i=6, it will
as it is, its value will for next stack value.)
(top 2)
--z (now second, it will execute and, z=1)(top 1)
++i (first it will execute and, i=6)(top 0)
now (++i + --z + i++ + --i * ++y)
(6+1+6+6*4)=(37)
it is output, say 37,for this printf("%d",++i + --z + i++
+ --i * ++y);
.................................................
Now Let me go with second statement, that is :
ans=++i + --z + i++ + --i * ++y;
here,
first of all ++y will contain the value of variable y=4
++y=4
after this, --i will less the value of variable i, say now
i = 4,
(--i=4),
after this, i++ will execute and, it will not increase the
value of variable i, right now, so value of i, say now i =
4, as it is.
after this, --z will less the value of variable z, say now
z = 1,
(--z=1)
now, ++i will increase the value of variable i.
Say i = 5.
.......................................................
now value of valiable i in memory is 5.
ans=5+1+5+5*4
ans=5+1+5+20
ans=31..........,
8 :: What is syntax error?
synatx error is a compile type error. it will occur when
the programmer doesnot follow the standard rules or
syntax of programming.
the programmer doesnot follow the standard rules or
syntax of programming.
9 :: What is meant for variable not found?
when u have not declared variable in the main function or
any other function but used in the program.
example:
main()
{
int i,j;----------------> (iSum not declared)
printf("enter the value of i and j");
scanf("%d%d",&i,&j);
iSum = i + j;
printf("The Sum =",iSum);
getch();
}
In this case iSum will Show a compiler error "Variable not
found".
any other function but used in the program.
example:
main()
{
int i,j;----------------> (iSum not declared)
printf("enter the value of i and j");
scanf("%d%d",&i,&j);
iSum = i + j;
printf("The Sum =",iSum);
getch();
}
In this case iSum will Show a compiler error "Variable not
found".
10 :: Errors are known as?
It's a human mistake associated with the program