UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Other than in a for statement, when is the comma operator used?

Asked by Last Modified  

Follow 1
Answer

Please enter your answer

Software Trainer

Example : int i,j; i=(10,20,30,40); j=10,20,30,40; printf("%d",i); printf("%d",j); // in this program output of i will be 40 and j will be 10 // In interviews you can face such type of comma operator related questions.
Comments

Professional Tutor with 15 years of experience.

Comma operator ( , ) is a binary operator. ------- USE ------- 1. for (first = s, s += len - 1; s >= first; --s) 2. ++p, ++q; 3. int a=1, b=2, c=3; 4. if (y = f(x), y > x) 5. if (failure) return (errno = EINVAL, -1); This can be written more verbosely as: if (failure) { errno =...
read more
Comma operator ( , ) is a binary operator. ------- USE ------- 1. for (first = s, s += len - 1; s >= first; --s) 2. ++p, ++q; 3. int a=1, b=2, c=3; 4. if (y = f(x), y > x) 5. if (failure) return (errno = EINVAL, -1); This can be written more verbosely as: if (failure) { errno = EINVAL; return -1; } 6. printf("Hello, %s!", "world"); 7. printf("Computer","Programming"); 8. void addition(n1,n2,ans); ....etc. read less
Comments

Thanks for the question Sanjay, The comma operator is commonly used to separate variable declarations, function arguments and expressions. Thanks, Team DishaaPro www.dishaapro.com
Comments

While if variables declaratios etc
Comments

Experienced faculty in C with data structures and C++ with Data Structures,Linux Admin with Advance linux concepts

Comma or seperator is used to seperate declarations in the program. Ex: Declaring three integer variables int a,b,c;
Comments

Software Engineer

in printf and scanf like so many is there ex: printf("%d",c); it is used to print the value of c
Comments

International Corporate Trainer For dotnet Core ,Angular 2 ,C ,C++ and LPT Marathi for RBI Banking

comma operatoris used in enum data type declaration enum color={violet,indigo,blue, green}
Comments

Professional Trainer:: Hadoop Big Data, DevOps, Perl, Python

its used only when we use assignment int a=1, b=2, c=3; it has nothing to do with for statement, the assignment which you are doing in for, is where it uses comma.
Comments

It can be used many places, for is not the only place.
Comments

In printf Statement we ll use Comma Operator. Ex: Printf("%d", a); But in for We ll use Semicolon Not comma.
Comments

View 18 more Answers

Related Questions

How to improve my c knowledge........
First learn the basic concepts of C .There is a book named Let Us C. It is a very good book with all the basics and concepts of C.I also have this book .I take classes of teaching basics of C,C++,java. Learn...
Anish
What are the main characteristics of c programming?
C programming is characterized by several key features that contribute to its popularity and versatility. Here are some of the main characteristics of the C programming language: Procedural Programming: ...
Balendra
0 0
6
Can the last case of a switch statement skip including the break?
Last case if a switch should be DEFAULT.. Good to have this case always. Executed only when there's no other matching cases found.
Sanjeev
Is it valid to address one element beyond the end of an array?
No, array is a fixed size memory allocation for variables. It is illegal to access elements beyond the allocated space.
Shivani
What is the benefit of using an enum rather than a #define constant?
The use of an enumeration constant (enum) has many advantages over using the traditional symbolic constant style of #define. These advantages include a lower maintenance requirement, improved program readability,...
Basundhara
0 0
7

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

C Program-Error Handling
//Header files #include<stdio.h>#include<conio.h>#include<stdlib.h> //Main function void main(){ int dividend=10; int divisor=0; int quotient; //Function for clearing screen clrscr(); ...

C PROGRAM FOR GENERATING SOUND
#include<stdio.h> #include<conio.h> #include<dos.h> void main() { sound(3000); // sound function have single parameter , this parameter we put integer value its generating...

V. Muthu Ganeshan

0 0
0

C Program-Error Handling[Program Exit Status]
//Header files #include<stdio.h>#include<conio.h>#include<stdlib.h> //Main Function void main(){ int dividend=20; int divisor=5; int quotient; //Function for clearing screen clrscr();...

Array vs Linked List
Array Linked List Accessing element is easy. Accessing element is difficult compare to Array. Easy to use. Difficult to use. Memory is Fixed size. Memory is variable size. If...

Some interview questions for freshers on C language
Q1. What are the two forms of #include? There are two variants of #include. The one is #include and the other one is #include”file”. In general the first form that is #include is used to...

Recommended Articles

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more