Programming Tutorials

(追記) (追記ここまで)

Simple arithmetic calculations in C

By: Jeffrey in C Tutorials on 2012年03月16日 [フレーム]

This simple C program shows simple arithmetic calculations.

#include <stdio.h>
// main() function-
int main()
{
 // variables declaration
 int x, y, z;
 // variables initialization, assign 20 to variable x-
 // or put the value of 20 in memory location labeled by x
 x = 20;
 y = 2;
 printf("Given x = 20, y = 2\n");
 printf("\nx / y = %d", x / y);
 // do some basic calculations
 x = x * y;
 y = y + y;
 printf("\nx = x * y");
 printf("\ny = y + y");
 printf("\nNew value for x / y = %d", x / y);
 z = 20 * y / x;
 printf("\nz = 20 * (y / x) = %d\n", z);
 return 0;
}



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /