C Programming Language: Checking Number of Subjects Chosen for a Course

  • #1
3
0
my friend i fail to perform this simple task can you please direct me how to approach a simple question like this
the quetion said "a registrar set up the curriculum for the term . One course may have up to 10 subject . Students must select a minimum of 6 subjects from a particular course .Once a student registers for the term , the billing system is notified so that the student may be billed .Student may use the system to add or drop subjects for the period of time of registration.\
write a C program that will check the number of subject s the student has chosen for a course .This program will run after the student has updated the subject selection. If the number of subject is less than 6 then an appropriate message should be displayed on the screen . The program should include a function that will count the number of subjects.
 
Technology news on Phys.org
  • #2
you start from something that compiles:
Code:
int main (void) {
  return 0;
}
and then add code as necessary.
 

1. How do I check the number of subjects I have chosen for a course in C programming language?

To check the number of subjects chosen for a course in C programming language, you can use the sizeof operator. This operator returns the size of a variable in bytes, which can be used to determine the number of subjects chosen based on the data type used.

2. Can I use a loop to check the number of subjects chosen for a course in C programming language?

Yes, you can use a loop to check the number of subjects chosen for a course in C programming language. You can use a for or while loop to iterate through an array or list of subjects and count the number of elements to determine the total number of subjects chosen.

3. Is there a built-in function in C programming language to check the number of subjects chosen for a course?

No, there is no built-in function in C programming language specifically for checking the number of subjects chosen for a course. However, you can use the sizeof operator or a loop to achieve the same result.

4. What happens if I exceed the maximum number of subjects allowed for a course in C programming language?

If you exceed the maximum number of subjects allowed for a course in C programming language, you may encounter errors or unexpected behavior in your program. It is important to carefully consider the maximum number of subjects allowed and handle any potential errors in your code.

5. Can I use a conditional statement to check the number of subjects chosen for a course in C programming language?

Yes, you can use a conditional statement like if or switch to check the number of subjects chosen for a course in C programming language. You can set conditions based on the number of subjects and handle different scenarios in your program accordingly.

Suggested for: C Programming Language: Checking Number of Subjects Chosen for a Course

Back
Top