0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C++版 C PuzzleBook

Posted at

The C Puzzle Book: Operators 1: Basic Arthmetic Operations
https://qiita.com/kaizen_nagoya/items/2a0d8277d72bfc579df6

のC++版

puzzle_op1.cpp
// The C Puzzle Book, Alan R. Feure, Printice Hall inc.
// Operators 1: Basic Arthmetic Operations
// https://qiita.com/kaizen_nagoya/items/2a0d8277d72bfc579df6
// Dr. Kiyoshi Ogawa
#define CPP
#ifdef CPP
#include <iostream>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#endif
int main(void)
{
  int x;
#ifdef CPP
  std::cout << "CPP\n";
  x = -3 + 4 * 5 - 6; std::cout << x << "\n"; //Chapter1.1)
  x = 3 + 4 % 5 - 6 ; std::cout << x << "\n"; //Chapter1.2)
  x = -3 * 4 % - 6 / 5; std::cout << x << "\n"; //Chapter1.3)
  x = ( 7 + 6 ) % 5 / 2; std::cout << x << "\n"; //Chapter1.4)
#else
  printf("C\n");
  x = -3 + 4 * 5 - 6; printf("%d\n",x); //Chapter1.1)
  x = 3 + 4 % 5 - 6 ; printf("%d\n",x); //Chapter1.2)
  x = -3 * 4 % - 6 / 5; printf("%d\n",x); //Chapter1.3)
  x = ( 7 + 6 ) % 5 / 2; printf("%d\n",x); //Chapter1.4)
#endif
  return EXIT_SUCCESS;
}

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?