Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
45 views
in C++ by (112k points)
What is the purpose of the percent sign (%) in C++?

Please log in or register to answer this question.

1 Answer

0 votes
by (112k points)

The percent sign (%) is used as the modulus operator in C++, which returns the remainder of a division operation. It is often used in arithmetic or mathematical operations.

Example code:

// Example of using the modulus operator
#include <iostream>
using namespace std;

int main() {
    int num1 = 10;
    int num2 = 3;
    int result = num1 % num2;
    cout << "The remainder is: " << result << endl;
    return 0;
}
 

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...