gyantonic
Login
Create Account
Home
Placement Preparation
Freshers Jobs
Questions
Career Discussions
Articles
Become Mentor
Students ! Create a Professional Resume in Minutes for FREE.
Answer the Question
1. a=5,what is the output of a++ and ++a?
2. i=3;
j=2*(i++);
k=2*(++i);
what is the output of j and k?
By :
nandigam anjali
On :
28-Dec-2012
Answers :
5
Report Abuse
Answer this Question
Existing Users - Login
*
Email Id :
*
Password :
Forgot Password
New Users - Create your Account
*
Email Id :
*
Password :
*
Confirm Password :
*
Full Name :
Share
|
Your Answer
Give your answer
Cancel
Previous Answers
1.for a++ gives a=5; and ++a gives a=6;
2.
On :
22-Jan-2013
Accept Count :
0
By :
Hemant Kumar Singh
Report Abuse
|
Accept Answer
|
Add Comment
stepwise answer is here:
(1)here a=5, (1) a=5,
(2)and a++=5, (2)++a=6
(3)and now a=6 (3) a=6
so answer is:
a++=5 and ++a=6
a++ is post operator, i.e. it's effect will be after one line and ++a is pre operator, i.e. it increases it's value first than performs other operations......
here is a great example for you ::::
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=1;
cout<<a<<endl;
cout<<a++<<endl;
cout<<a<<endl<<endl;
b=5;
cout<<b<<endl;
cout<<++b<<endl;
cout<<b<<endl;
getch();
}
o/p:::::
1
1
2
5
6
6
On :
22-Jan-2013
Accept Count :
0
By :
sandeep kuraria
Report Abuse
|
Accept Answer
|
Add Comment
1.a++=6,++a=6
2.j=8,k=8
On :
19-Jan-2013
Accept Count :
0
By :
CHITRA
Report Abuse
|
Accept Answer
|
Add Comment
1)a++=5, ++a=6
2)j=6,k=12
On :
10-Jan-2013
Accept Count :
0
By :
yadav komal
Report Abuse
|
Accept Answer
|
Add Comment
j=6 k=10
On :
29-Dec-2012
Accept Count :
0
By :
Anil kumar
Report Abuse
|
Accept Answer
|
Add Comment
Add a Question
Latest Answers
YOU HAVE 9 DOTS AND U HAVE TO JOIN THEM WITH FOUR LINES ,REMEMBER THAT THE LINES SHOU.....
A boat's speed with the current is 20 km/hr and the speed of the current is 5 km/hr. .....
Generally asked question In SSC On pipes and cistern Concept : Pipe A can fill in.....
Hi I am sharing Aptitude question which are generally asked in the interview : If 2x.....
What are manipulators?
Two boats are sailing in the sea on the two sides of a lighthouse. The angle of eleva.....
A right triangle with sides 3cm (base),4cm (perpendicular) is rotated the side of 3 c.....