Created
April 4, 2012 18:54
-
-
Save sinannar/2304730 to your computer and use it in GitHub Desktop.
HW01-ahmetsoyyiğit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BU DOSYALAR DİZİSİ FACEBOOK GRUBU OLAN C AND JAVA PROGRAMMING DE VERILEN HW01 IN KODLARIDIR | |
ODEV DDOSYASI: | |
https://docs.google.com/document/pub?id=1ImUBZNdu-AD67zOnkErvpY8Y6OuojDgFWMD9kQqIDaQ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 | |
5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*################################################################*/ | |
/* 1.odev.c */ | |
/* ---------------------- */ | |
/* Created on 26.02.2012 by Ahmet Soyyiğit */ | |
/* */ | |
/* Description */ | |
/* ----------------------- */ | |
/* This program computes *,/,+ and - of 2 numbers */ | |
/* and gives us the results. */ | |
/* */ | |
/*################################################################*/ | |
#include <stdio.h> | |
int main(){ | |
int firstNumber, secondNumber; | |
int resultMul, resultDiv, resultAdd, resultExt; | |
/*Get the numbers*/ | |
printf("Enter first number: \n"); | |
scanf("%d", &firstNumber); | |
printf("Enter second number: \n"); | |
scanf("%d", &secondNumber); | |
/*Compute the numbers*/ | |
resultMul = firstNumber * secondNumber; | |
resultDiv = firstNumber / secondNumber; | |
resultAdd = firstNumber + secondNumber; | |
resultExt = firstNumber - secondNumber; | |
/*Show the results*/ | |
printf("Result of multiplication = %d \n", resultMul); | |
printf("Result of division = %d \n", resultDiv); | |
printf("Result of addition = %d \n", resultAdd); | |
printf("Result of extraction = %d \n", resultExt); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*################################################################*/ | |
/* Ödev 3 */ | |
/* ---------------------- */ | |
/* Created on 27.02.2012 by Ahmet Soyyiğit */ | |
/* */ | |
/* Description */ | |
/* ---------------------- */ | |
/* This implementation gets 2 numbers from input file and */ | |
/* calculate their addition, division, multiply and expression. */ | |
/* Than, writes it on output file */ | |
/* */ | |
/* Notes */ | |
/* --------------------- */ | |
/* This is my homework. */ | |
/* */ | |
/* References */ | |
/* --------------------- */ | |
/* Thanks to everyone, especially Sinan Abi :) */ | |
/* */ | |
/*################################################################*/ | |
/*################################################################*/ | |
/* Includes */ | |
/*################################################################*/ | |
#include <stdio.h> | |
/*################################################################*/ | |
/* int main() */ | |
/* ---------- */ | |
/* Return */ | |
/* ---------- */ | |
/* 0 on success */ | |
/*################################################################*/ | |
int main(){ | |
int firstNumber, secondNumber; | |
int resultMul, resultDiv, resultAdd, resultExt; | |
/*File definitions*/ | |
FILE *inputFile, *outputFile; | |
inputFile = fopen("input.in", "r"); | |
outputFile = fopen("output.out","w"); | |
/*Get the numbers*/ | |
printf("\nGot the first number. \n"); | |
fscanf(inputFile, "%d", &firstNumber); | |
printf("Got the second number. \n"); | |
fscanf(inputFile, "%d", &secondNumber); | |
/*Compute the numbers*/ | |
resultMul = firstNumber * secondNumber; | |
resultDiv = firstNumber / secondNumber; | |
resultAdd = firstNumber + secondNumber; | |
resultExt = firstNumber - secondNumber; | |
/*Show the results*/ | |
fprintf(outputFile, "Result of multiplication = %d \n", resultMul); | |
fprintf(outputFile, "Result of division = %d \n", resultDiv); | |
fprintf(outputFile, "Result of addition = %d \n", resultAdd); | |
fprintf(outputFile, "Result of extraction = %d \n", resultExt); | |
printf("Calculations are done and written on the output file.\n\n"); | |
fclose(inputFile); | |
fclose(outputFile); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*################################################################*/ | |
/* Ödev 3 */ | |
/* ---------------------- */ | |
/* Created on 27.02.2012 by Ahmet Soyyiğit */ | |
/* */ | |
/* Description */ | |
/* ---------------------- */ | |
/* This implementation computes the capacity and */ | |
/* lateral area of a cylinder(lateral area will be written */ | |
/* on output file). */ | |
/* */ | |
/* Notes */ | |
/* --------------------- */ | |
/* This is my homework. */ | |
/* */ | |
/* References */ | |
/* --------------------- */ | |
/* Thanks to everyone, especially Sinan Abi :) */ | |
/* */ | |
/*################################################################*/ | |
/*################################################################*/ | |
/* Includes */ | |
/*################################################################*/ | |
#include <stdio.h> | |
#define PI_NUMBER 3.14 /* Pi number for formulas. */ | |
#define TWO_FOR_FORMULA 2 /*Formula of lateral:2πrh */ | |
/*################################################################*/ | |
/* int main() */ | |
/* ---------- */ | |
/* Return */ | |
/* ---------- */ | |
/* 0 on success */ | |
/*################################################################*/ | |
int main(){ | |
int radius, height; /*radius and height of cylinder */ | |
double capacityOfCylinder, lateralArea; | |
/*File definitions*/ | |
FILE *outputFile; | |
outputFile = fopen("output.out","w"); | |
/*Get the radius and height*/ | |
printf("Please enter the radius of cylinder: "); | |
scanf("%d", &radius); | |
printf("Please enter the height of cylinder: "); | |
scanf("%d", &height); | |
/*Calculate capacity and lateral area*/ | |
capacityOfCylinder = PI_NUMBER * radius * radius * height; | |
lateralArea = TWO_FOR_FORMULA * PI_NUMBER * radius * height; | |
printf("The capacity of cylinder is %f .\n", capacityOfCylinder); | |
/*Print it on the output file*/ | |
fprintf(outputFile ,"The lateral area of cylinder is %f .", lateralArea); | |
fclose(outputFile); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment