Linked Questions

Ask Question
210 questions linked to/fromWhat does the comma operator , do?
93votes
20answers
24kviews

You see it used in for loop statements, but it's legal syntax anywhere. What uses have you found for it elsewhere, if any?
pythonic metaphor's user avatar
35votes
7answers
3kviews

With reference to Comma-Separated return arguments in C function [duplicate],x=x+2,x+1;will be evaluated asx=x+2; However, in case of the following code#include<stdlib.h>#include<...
Ashish Kumar's user avatar
39votes
3answers
4kviews

#include<stdio.h> int main(void) { int a; a = (1, 2), 3; printf("%d", a); return 0;}output: 2Can any one explain how output is 2?
Kr Arjun's user avatar
26votes
1answer
2kviews

Consider:for (auto i = 0; i < g.size(); ++i) for (auto j = 0; j < g.size(); ++j) if (g[i][j] == 0) dfs(g, i, j), ++regions;return regions;I don't like one line code. What does the code ...
Gilad's user avatar
  • 6,625
11votes
3answers
12kviews

Prog 1: #include<stdio.h> int main() { int i=0; while(i<=8,i++); printf("%d",i); return 0; }Prog 2:#include<stdio.h> int main(){ int i=0; while(i++,i&...
8votes
4answers
3kviews

While completing a C programming test, I was given a question regarding the expected output from a function which seem to return two values. It was structured as follows:int multi_return_args(void)...
user1556232's user avatar
5votes
4answers
592views

int main(void){ int a=0, b=20; char x=1, y=10; if(a,b,x,y) printf("bye"); return 0;}How does "if" condition in the above code work work?Would the value of "y" be only considered by "if"...
sreejith.virgo's user avatar
7votes
7answers
2kviews

Possible Duplicate: What does the ',' operator do in C? Ok I had an interview today and they asked me what should be the output of the following code#include<stdio.h>int main (){...
Registered User's user avatar
6votes
1answer
6kviews

int main(){ switch(1,2) { case 1:printf("1");break; case 2:printf("2");break; default: printf("error");break; }}Is this valid in c?I thought it shouldn't be , but when ...
4votes
3answers
623views

#include<stdio.h>#define POOLNAME_FMT "Hello"void main() { printf((POOLNAME_FMT "Cannot allocate %d bytes" POOLNAME_FMT "in pool not enough memory",5));}Why does it give segmentation ...
4votes
4answers
802views

I was reading some material about errors that should be avoided when writing C programs and I came across the following code:#include <stdio.h>void foo(int param){ printf("foo is called\n"...
rkachach's user avatar
2votes
5answers
5kviews

I can't understand how this works and why it produces the following output.int main(){ int i=0; int a=5; int x=0; for(i=0; i<5; x=(i++,a++)) { printf("i=%d a=%d x=%...
Gopal's user avatar
1vote
7answers
1kviews

main(){ int i=0,j=0; while(i<5,j<10) { i++; j++; } printf("%d,%d,",i,j);}output: 10,10int main(){ int x=2,y=2; while(x<=5,y<=3) ...
4votes
2answers
333views

I'm studying C and I came across the code below. The printed results are always the same for all the printf calls. What does [x,y] mean? A memory address or something else?printf("%d ", array[0,0]...
A.Sim's user avatar
2votes
2answers
427views

I have written a C program where I declared a function reverse(int i). When I compile and run the program, it runs fine despite passing two arguments like this reverse((i++, i)). Why doesn't this ...
Deep Learner's user avatar

153050per page
1
2345
14