mustaphos
MB Üyesi
- Kayıt
- 14 Eylül 2015
- Mesajlar
- 35
- Tepkiler
- 8
- Yaş
- 29
- Meslek
- Öğrenci
- Üniv
- Anadolu University
Merhabalar.
Bu projeyi kendimi geliştirmek için yazmıştım.
Program önce bir değer ister. Değer 0 dan küçükse iki tane floating point ister ve bunları karşılaştırır. Eğer değer 0 ile 10 arasında ise kullanıcıdan ad ve soyad ister. Eğer değer 10 dan büyük ise değerin 10 dan büyük olduğunu söyler. Program en sonda girilen sayıların aritmetik ortalamasını da hesaplar.
İyi çalışmalar.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void main ()
{
int integer;/* The integer variable was defined as a int */
float f1;/* The f1 variable was defined as a float */
float f2;/* The f2 variable was defined as a float */
char name[15];/* The name variable was defined as a char with 15 character */
char surname[15];/* The surname variable was defined as a char with 15 character */
float average;/* The average variable was defined as a float*/
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write an integer : ");
scanf("%d",&integer);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write the first floating point : ");
scanf("%f",&f1);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write the second floating point : ");
scanf("%f",&f2);
printf("**************************************************\n");
printf("**************************************************\n");
printf("**************************************************\n");
if ( integer < 0 )/* If integer is less than 0 */
{
if ( f1 > f2 )/* If f1 is greater than f2 */
{
printf("[ %f ] is greater than [ %f ] . \n",f1,f2);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( f2 > f1 )/* If f2 is greater than f1 */
{
printf("[ %f ] is greater than [ %f ] . \n",f2,f1);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( f1 == f2 )/* If f1 is equal to f2 */
{
printf("[ %f ] is equal to [ %f ] . \n",f1,f2);
printf("**************************************************\n");
printf("**************************************************\n");
}
}
else if ( integer >= 0 && integer <= 10 )/* If integer is less and equal than 10 and more and equal than 0 */
{
printf("Please write your name : ");
scanf("%s",&name);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write surname : ");
scanf("%s",&surname);
printf("**************************************************\n");
printf("**************************************************\n");
printf("**************************************************\n");
printf("Your name is : [ %s ] \n",name);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Your surname is : [ %s ] \n",surname);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( integer > 10 )/* If integer is more than 10 */
{
printf("The integer [ %d ] is greater than 10 . \n",integer);
printf("**************************************************\n");
printf("**************************************************\n");
}
average = (integer+f1+f2)/3;/* Calculate the average */
printf("The average of entered number is [ %f ] . \n",average);
printf("**************************************************\n");
printf("**************************************************\n");
getch();
}
Bu projeyi kendimi geliştirmek için yazmıştım.
Program önce bir değer ister. Değer 0 dan küçükse iki tane floating point ister ve bunları karşılaştırır. Eğer değer 0 ile 10 arasında ise kullanıcıdan ad ve soyad ister. Eğer değer 10 dan büyük ise değerin 10 dan büyük olduğunu söyler. Program en sonda girilen sayıların aritmetik ortalamasını da hesaplar.
İyi çalışmalar.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void main ()
{
int integer;/* The integer variable was defined as a int */
float f1;/* The f1 variable was defined as a float */
float f2;/* The f2 variable was defined as a float */
char name[15];/* The name variable was defined as a char with 15 character */
char surname[15];/* The surname variable was defined as a char with 15 character */
float average;/* The average variable was defined as a float*/
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write an integer : ");
scanf("%d",&integer);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write the first floating point : ");
scanf("%f",&f1);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write the second floating point : ");
scanf("%f",&f2);
printf("**************************************************\n");
printf("**************************************************\n");
printf("**************************************************\n");
if ( integer < 0 )/* If integer is less than 0 */
{
if ( f1 > f2 )/* If f1 is greater than f2 */
{
printf("[ %f ] is greater than [ %f ] . \n",f1,f2);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( f2 > f1 )/* If f2 is greater than f1 */
{
printf("[ %f ] is greater than [ %f ] . \n",f2,f1);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( f1 == f2 )/* If f1 is equal to f2 */
{
printf("[ %f ] is equal to [ %f ] . \n",f1,f2);
printf("**************************************************\n");
printf("**************************************************\n");
}
}
else if ( integer >= 0 && integer <= 10 )/* If integer is less and equal than 10 and more and equal than 0 */
{
printf("Please write your name : ");
scanf("%s",&name);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Please write surname : ");
scanf("%s",&surname);
printf("**************************************************\n");
printf("**************************************************\n");
printf("**************************************************\n");
printf("Your name is : [ %s ] \n",name);
printf("**************************************************\n");
printf("**************************************************\n");
printf("Your surname is : [ %s ] \n",surname);
printf("**************************************************\n");
printf("**************************************************\n");
}
else if ( integer > 10 )/* If integer is more than 10 */
{
printf("The integer [ %d ] is greater than 10 . \n",integer);
printf("**************************************************\n");
printf("**************************************************\n");
}
average = (integer+f1+f2)/3;/* Calculate the average */
printf("The average of entered number is [ %f ] . \n",average);
printf("**************************************************\n");
printf("**************************************************\n");
getch();
}