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

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

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

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

Tutor

Comma operator can also be used in other statements like printf(), scanf() e.g printf("The number entered is %d", num); It can also be used for separating the variables while declaring e.g int num1, num2,num3; Separating the arguments during function declaration
Comments

Tutor

We also use comma for passing multiple arguments to a function.
Comments

C/C++/SQL/Datastructures/Database/Excel

There are lot many places, printf, scanf, sequence of delaration, argument passing etc.
Comments

While if variables declaratios etc
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

Tutor

We don't use comma in for loop, we use semi-colon Apart from that semi-colon are used for terminating C commands
Comments

View 18 more Answers

Related Questions

What is meant by "bit masking"?
For example if you want to know if third bit is 1 or not for an int x then you can mask all other bits and just check the third one: (n & 0x04) != 0 means 3rd bit is not zero, 0x04 is the bit mask
Kiran
0 0
6
Who founded the C language? Why?
The C programming language was developed by Dennis Ritchie at Bell Labs in the early 1970s. Ritchie, along with his colleague Ken Thompson, created C as an evolution of the B programming...
Santosini
0 0
7
How would you round off a value from 1.66 to 2.0?
By adding 1.0 (float) to the integer part (type casted) of 1.66.
Dhanya
0 0
6
How do I start learning C programming and finish it in one month?
Use a book named "Let us C"by yashwant t kanetkar. Or simply by taking a class from teachers on urbanpro
Pallavi
0 0
8
What is a pragma?
In computer programming, a directive pragma is a language construct that specifies how a compiler should process its input. The ' #pragma ' directive is the method specified by the C standard for providing...
Anil

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

Ask a Question

Related Lessons

Functions In C Programming
A C-language program is nothing but collection of Function, these are the building blocks of a ‘C’ program. Generally, a function mans a task. “Function is a...

An Interesting discussion about malloc( ) and calloc( )
What are malloc( ) and calloc( )? Simply putting they are the predefined functions in C language. Malloc( ) and calloc( ) are two such functions which are used for more or less identical purpose and...

C Program-String Palindrome
//Header files #include<stdio.h>#include<conio.h>#include<string.h> //Main function void main(){ char mystring; int i,length; int flag=0; //Function for clearing screen clrscr();...
S

Bit wise operators in C
Bit Wise Operators Bit Wise operators are manipulates of individual bits with in a word of memory. The bit wise operators can be divided in to three general category. One’s Complement...

Introduction to Programming Languages
What is a Programming Language? A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages...

Recommended Articles

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 >

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 >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

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