İçeriğe geç
ShiftDelete.Net
Haber ara/ SDN'ye SorGiriş
Haber Akışı SDNTV İnceleme Forum Yapay Zeka Akıllı Telefon Elektrikli Otomobil Oyun ShiftDelete.Net Global Teknoloji Haberleri Mobil Otomobil Donanım Savunma Bilim Sosyal Medya İnternet Giyilebilir Teknoloji Rehber Ürünler Son dakika Yazarlar
  1. Ana sayfa
  2. Topluluk
  3. Yazılım
  4. Diğer Yazılım Konuları
Diğer Yazılım Konuları

code block -işlem hatası

neslee29.08.20210 cevap1.170 görüntüleme
2021'den beri4 mesaj
#1
#include<stdio.h>
#include<stdbool.h>
double resultOfEquation(int n);
bool isPrime(int number);
int entered,m,control_integer = 0;
int a,b,h;
float u;
int k, num;
unsigned long long fact=1LL;
int factorialOfNumber(int num);
char* Weekdays(int numb);
int main()
{
int choice, n, number, a, b, h, u,k,i,m,num,y, numb;
int choice1=1;
while(choice1 ==1)
{
printf("\n chose a number: ");
printf("\n 1. Calculate the result of the equation ");
printf("\n 2. find a number is prime or not ");
printf("\n 3. calculation the area of a trapezium ");
printf("\n 4. calculate the factorial of a number ");
printf("\n 5. Find the weekday ");
printf("\n Enter your choice: ");
scanf("%d", &choice);
switch(choice)
{
case(1):
printf("\n Enter the value of n to find the result of an equation: ");
scanf("%d", &n);
double res = resultOfEquation(n);
printf("\n RESULT OF AN EQUATION IS: %f \n",res);
break;
case(2):
printf("enter a number:");
scanf("%d",&entered);
for (i=2; m< entered ; m++)
{
if (entered % m == 0)
{
printf("the number entered is not prime.");
control_integer = 1;
break;
}
}
if (control_integer == 0)
printf("the number entered is prime.");
break;
case(3):
printf ("please enter the edges:\n");
printf("a edge(lower base):");
scanf("%d",&a);
printf("b edge(upper base):");
scanf("%d",&b);
printf("h(height):");
scanf("%d",&h);
float u;
u=((a+b)*h)/2;
printf("area of a trapezium: %.2f",u);
break;
case(4):
printf("enter any number to calculate factorial:");
scanf("%d",&num);
for (k=1; k<=num; k++)
{
fact=fact*k;
}
printf("factorial of %d = %llu",num,fact);
case(5):
x:
printf("\n Enter a number between (1-7) to find it's week day: ");
scanf("%d", &numb);
if(numb<=0 && numb>7)
{
printf("\n Invalid input. Please enter valid number!!");
goto x;
}
else
{
printf("\n Weekday is: %s",Weekdays(numb));
}
break;
}
printf("\n Do you want to continue again? (1 or 2): ");
int choice1;
scanf("%d", &choice1);
if(choice1==2)
{
break;
}
}
}
double resultOfEquation(int n)
{
int i;
double result1 = 0;
for(i=1;i<=n;i++)
{
result1 = result1 + ((2*2)-3)/(2*2);
}
return result1;
}
bool isPrime(int number)
{
int flag = true;
if (number <= 1)
{
flag = false;
}
else
{
int j;
for (j = 2; j <= number / 2; j++)
{
if ((number % j) == 0)
{
flag = false;
break;
}
}
}
}
double areaOfTrapezium(int lower_base, int upper_base, int height)
{
double area = ((lower_base+upper_base)*height)/2;
return area;
}
int factorialOfNumber(int num)
{
int fact = 1;
int y;
for(y=num;y>=1;y--)
{
fact = fact *y;
}
return fact;
}
char* Weekdays(int numb)
{
if(numb == 1)
{
return "Monday";
}
else if(numb == 2)
{
return "Tuesday";
}
else if(numb == 3)
{
return "Wedenesday";
}
else if(numb == 4)
{
return "Thursday";
}
else if(numb == 5)
{
return "Friday";
}
else if(numb == 6)
{
return "Saturday";
}
else if(numb == 7)
{
return "Sunday";
}
}

^^^^^^^^^^^^^^^^^^^^^^
kod çalışıyor ama çalıştırdığımda 1. işlemi seçtiğimde sonucu yanlış veriyor. hep sıfır çıkıyor sonuç.hatayı bulamadım lütfen yardım edin.

Cevabını yaz

Cevap yazmak için giriş yap ya da üye ol. Eski forum kullanıcı adın ve parolanla girebilirsin.