Yam Code
Sign up
Login
New paste
Home
Trending
Archive
English
English
Tiếng Việt
भारत
Sign up
Login
New Paste
Browse
#include <stdio.h> #include <stdlib.h> #define ENTER 10 /* BAI TAP 1 */ int calculator(double number1, double number2, char op){ double res; switch(op){ case '+': res = number1 + number2; break; case '-': res = number1 - number2; break; case '*': res = number1 * number2; break; case '/': res = number1 / number2; break; } return res; } int baiTap1() { double number1, number2, res; char op; printf("Your operator : "); scanf("%c", &op); printf("Your 1st number : "); scanf("%lf", &number1); printf("Your 2nd number : "); scanf("%lf", &number2); res = calculator(number1, number2, op); printf("Result of: %lf %c %lf = %lf", number1, op, number2, res); return 0; } /* BAI TAP 2 */ int taxFreeIncome(){ double pendPersonal = 9000000, pendDependent = 3600000; int dependentAmount; printf("Number of Dependent : "); scanf("%d", &dependentAmount); double taxFree; taxFree = 12 * (pendPersonal + dependentAmount * pendDependent); return taxFree; } double percentTax(double taxableIncome) { if(taxableIncome > 18000000) return 20; if(taxableIncome <= 18000000) return 15; if(taxableIncome <= 10000000) return 10; if(taxableIncome <= 5000000) return 5; if(taxableIncome <= 0) return 0; } int baiTap2() { double yourIncome, taxFree, taxableIncome, incomeTax; printf("Your Income : "); scanf("%lf", &yourIncome); taxFree = taxFreeIncome(); printf("Tax-free Income : %lf \n", taxFree); taxableIncome = yourIncome - taxFree; if(taxableIncome <= 0) taxableIncome = 0; printf("Taxable Income : %lf \n", taxableIncome); incomeTax = taxableIncome * percentTax(taxableIncome) / 100; printf("Income Tax : %lf", incomeTax); return 0; } /* BAI TAP 3*/ int baiTap3() { int sum, input; sum = 0; do { printf("Type a random number: "); scanf("%d", &input); if(input != 0) sum += input; } while (input != 0); printf("Sum : %d", sum); return 0; } /* BAI TAP 4*/ int baiTap4() { int x,y,t; do { printf("x = "); scanf("%d", &x); printf("y = "); scanf("%d", &y); t = x; x = y; y = t; printf("x : %d, y : %d \n", x, y); } while (x != 0 && y != 0); return 0; } /* BAI TAP 5*/ int baiTap5() { int nVowels = 0, nConsonants = 0, nOthers = 0; char ch; printf("Input something then ENTER\n\n"); do { ch = getchar(); ch = toupper(ch); if(ch >= 'A' && ch <= 'Z'){ switch(ch){ case 'A': case 'E': case 'I': case 'O': case 'U': nVowels++; break; default: nConsonants++; } } else { nOthers++; } } while ( ch != ENTER); printf("\nnVowels: %d\n", nVowels); printf("nConsonants: %d\n", nConsonants); printf("nOthers: %d\n", nOthers - 1); return 0; } /* BAI TAP 6*/ int baiTap6() { int code; for(code = 0; code <= 255; code++){ printf("%c : %d, %o, %X\n", code, code, code, code); if(code != 0 && code % 20 == 0) { printf("Type to continuous..."); getchar(); }; } return 0; } /* BAI TAP 7 */ int baiTap7() { char char1, char2, t; int dif, code; printf("Input char 1 : "); char1 = getchar(); getchar(); printf("Input char 2 : "); char2 = getchar(); if(char1 > char2){ t = char1; char1 = char2; char2 = t; } dif = char2 - char1; printf("Difference = %d\n", dif); for(code = char1; code <= char2; code++){ printf("%c : %d, %o, %X\n", code, code, code, code); } return 0; } int main() { baiTap7(); // Dung baiTap nao thi doi thanh cai day return 0; }
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Tiếng Việt
भारत