C Programming Example - Division of Two Numbers | Tutorial
Tutorial -- Learning not just skills, but dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
C Tutorial
C Tutorial C Introduction C Environment Setup C VScode C Program Structure C Basic Syntax C Data Types C Variables C Constants C Storage Classes C Operators C Decision Making C Loops C Functions C Scope Rules C Arrays C enum (Enumeration) C Pointers C Function Pointers and Callback Functions C Strings C Structures C Unions C Bit Fields C typedef C Input & Output C File I/O C Preprocessors C Header Files C Type Casting C Error Handling C Recursion C Variable Arguments C Memory Management C Undefined Behavior C Command Line Arguments C Safe Functions C Sorting Algorithms C Project Structure C Examples C Classic 100 Examples C Quiz
C Standard Library
C Standard Library - Reference Manual C Standard Library - <assert.h> C Standard Library - <ctype.h> C Standard Library - <errno.h> C Standard Library - <float.h> C Standard Library - <limits.h> C Standard Library - <locale.h> C Standard Library - <math.h> C Standard Library - <setjmp.h> C Standard Library - <signal.h> C Standard Library - <stdarg.h> C Standard Library - <stddef.h> C Standard Library - <stdio.h> C Standard Library - <stdlib.h> C Standard Library - <string.h> C Standard Library - <time.h> C Standard Library <stdbool.h> C Standard Library <stdint.h> C Standard Library <inttypes.h> C Standard Library <complex.h> C Standard Library <tgmath.h> C Standard Library <fenv.h>
C Programming Example - Division of Two Numbers
Divide two numbers. If there is a remainder, output the remainder.
Example
#include<stdio.h>
int main()
{
int dividend, divisor, quotient, remainder;
printf("Enter dividend: ");
scanf("%d", ÷nd);
printf("Enter divisor: ");
scanf("%d", &divisor);
// Calculate quotient
quotient = dividend / divisor;
// Calculate remainder
remainder = dividend % divisor;
printf("Quotient = %dn", quotient);
printf("Remainder = %d", remainder);
return 0;
}
Output:
Enter dividend: 5
Enter divisor: 2
Quotient = 2
Remainder = 1
YouTip