Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have tried a lot but I didn't get solved will you help me out with this
thank you...!!

C++
#include <stdio.h> 
int main() 
{   
  int a=(1, 2, 3);   
  int b=(3, 2, 1);   

  for(; a>0; a--)      
    for(; b<3; b++);        

  printf("%d ", a*b); 

  return 0; 
}


What I have tried:

want expiation with suitable figure
Posted
Updated 24-Oct-17 8:15am
v3
Comments
CPallini 24-Oct-17 15:55pm    
OUt of curiosity, where did you find such a code?

Look into C's comma operator. When you know how that works, you will know what a and b will be initialized to.
 
Share this answer
 
Comments
CPallini 24-Oct-17 15:54pm    
5.
The Comma operator looks like this:
C++
x = a, b;
It evaluates the expression a, discards the result, evaluates b and returns it.
So the code for a and b both get executed, and x is set to the value of b.

Your code is just an extension of that: effectively
C++
x = ((a, b) , c);
So it evaluates a and b, then evaluates c and sets x to that value.
I.e. Your code is:
C++
int main() 
{   
  int a = 3;   
  int b = 1;   
 
  for(; a>0; a--)      
    for(; b<3; b++);        
      printf("%d ", a*b); 
  return 0; 
}
 
Share this answer
 
Comments
CPallini 24-Oct-17 15:55pm    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900