Showing posts with label Calculate. Show all posts
Showing posts with label Calculate. Show all posts

C Programm zur Berechnung von Umfang und Flächeninhalt verschiedener geomatrischer Figuren

C Programm zur Berechnung von Umfang und Flächeninhalt verschiedener geomatrischer Figuren

C Program for calculating the volume and acreage different geometric figures.


Solution For C Program :

/* C Program for calculating the volume and acreage different geometric figures.*/

#include <stdio.h>
#include <string.h>

/* KONSTANTEN */
#define RECHTECK 1
#define DREIECK 2
#define KREIS 3
#define YES 'y'
#define ENDE 0
#define PI 3.14159265358979323846

/* PROTOTYPEN */
void rechteck(float, float);
void dreieck(float, float);
void kreis(float);
int control(void);
int menue(void);
float wertlesen();




//int *feld;
int feld[] = { 0,0 };
float umfang = 0.0;
float radius = 0.0;
float flaeche = 0.0;




rechteck(seiteA, seiteB)
{
float flaeche = 0.0;
float umfang = 0.0;
flaeche = seiteA*seiteB;
umfang = (2*seiteA)+(2*seiteB);
feld[0] = flaeche;
feld[1] = umfang;
printf("feld[0]: %d",feld[0]);
printf("feld[1]: %d",feld[1]);
}

dreieck(seite, hoehe)
{
float flaeche = 0.0;
flaeche = (seite*hoehe)/2;
feld[0] = flaeche;
//return flaeche;
}
kreis(radius)
{
float flaeche = 0.0;
float umfang = 0.0;
int r;
int u;
*r = radius*radius*PI;
*u = 2*PI*radius;
}

int main(void)
{
control();
}
/* Menüsteuerung */
menue(void)
{
int pruefeEingabe = 0;
int nutzerauswahl = 0;
char endzeichen = '\0';
printf("Bitte waehlen Sie:\n");
printf("1: Rechteck\n");
printf("2: Dreieck\n");
printf("3: Kreis\n");
printf("0: Beenden\n");
do
{
printf("\nBitte treffen Sie eine gültige Auswahl:\n");
// Nutzereingabe zur Menüauswahl
pruefeEingabe = scanf("%d%c",&nutzerauswahl,&endzeichen);
fflush(stdin);
}
while(pruefeEingabe !=2 || endzeichen != '\n'); //Ausschluss falscher Eingaben durch Benutzer
return nutzerauswahl;
}

/* Funktion zum Einlesen der notwendigen Zahlen für die Funktionen 1 bis 3 */
float wertlesen()
{
int pruefeEingabe = 0;
float zahl = 0.0;
char endzeichen = '\0';
do
{
// printf("Bitte geben Sie eine positive Zahl ein:\n");
// Nutzereingabe für Werte
pruefeEingabe = scanf("%f%c",&zahl,&endzeichen);
fflush(stdin);
}
while(pruefeEingabe !=2 || endzeichen != '\n' || zahl < 0);
printf("\n");
return zahl;
}

/* Kontroll-Funktion */
int control(void)
{
float *rzeiger;
int *uzeiger;
int *fzeiger;
rzeiger = &radius;
uzeiger = &umfang;
fzeiger = &flaeche;
int nutzerauswahl = 0;
float ersteZahl=0.0;
float zweiteZahl=0.0;
//float ergebnis = 0.0;
char endzeichen = '\0';
char weiter = '\0';
/* Startbedingungen und Überprüfung */
do
{
if(weiter!=YES)
{
// Ansteuerung des Menü
nutzerauswahl=menue();
// switch-case zur Menüsteuerung
switch(nutzerauswahl)
{
case RECHTECK: // Wertelesen
printf("\nBitte Laenge der Seite a eingeben: ");
ersteZahl=wertlesen();
printf("\nwertlesen: %f", ersteZahl);
printf("\nBitte Laenge der Seite b eingeben: ");
zweiteZahl=wertlesen();
printf("\nwertlesen: %f", zweiteZahl);
// Funktionsaufruf
rechteck(ersteZahl, zweiteZahl);
printf("\nDie Flaeche betraegt: %d.", feld[0]);
printf("\nDer Umfang betraegt: %d.", feld[1]);
break;
case DREIECK: // Wertelesen
printf("\nBitte Laenge der Grundseite eingeben: ");
ersteZahl=wertlesen();
printf("\nBitte Hoehe eingeben: ");
zweiteZahl=wertlesen();
// Funktionsaufruf
// ergebnis=dreieck(ersteZahl, zweiteZahl);
// Ergebnisauswertung
// printf("\nDie Flaeche betraegt: %d.",ergebnis);
printf("\nDie Flaeche betraegt: %d.", feld[0]);
break;
case KREIS: // Funktionsaufruf
printf("\nBitte Radius eingeben: ");
ersteZahl = wertlesen();
printf("\nDie Flaeche betraegt: %d.", *rzeiger);
printf("\nDer Umfang betraegt: %d.", *uzeiger);
break;
case ENDE: printf("\n\n");
break;
default: printf("\nSie haben keine gültige Auswahl getroffen.\n");
}
}
// Steuerung der Abbruchkriterien
else
{
nutzerauswahl=ENDE;
}
if(nutzerauswahl!=ENDE)
{
printf("\nWollen Sie das Programm beenden? y - ja, sonst beliebiges Zeichen angeben.\n");
// Nutzereingabe zur Wiederholung oder dem Abbruch des Programms
scanf("%c%c",&weiter,&endzeichen);
fflush(stdin);
if(weiter == YES && endzeichen != '\n')
{
nutzerauswahl=ENDE;
}
printf("\n\n");
}
}
while(nutzerauswahl!=ENDE);
}

Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.

Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.

Write a function that calculates the geometric function in an array NxM elements from the elements with values ​​even located under the main and over the opposite diagonal .



Solution For C Program :

// Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.

float average (int tab[N][M])
{
int i,j,iloczyn=1;
for(i=0;i<N;i++)
   for(j=0;j<M;j++)
      if(i>j && i<(N-1)-j && i&1==0)
        iloczyn*=tab[i][j];
return pow(iloczyn, (1/(N*M)));
}

C Program to Calculate GCD using recursion

How to write a C Program to calculate Greatest Common Divisor using recursion in C Programming Language ?

Solution For C Program :

/*C Program to calculate Greatest Common Divisor using recursion.*/

#include<stdio.h>
void main()
{
int gcd(int,int);
int a, b, result;
printf("\nEnter Any Two Values : ");
scanf("%d%d", &a, &b);
result = gcd(a, b);
printf("\nThe GCD of %d and %d is %d.", a, b, result);
}
int gcd(int x, int y)
{
int temp, n;
temp = x % y;
if(temp != 0)
{
n = gcd(y, temp);
return(n);
}
if(temp == 0)
return y;
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Calculate First Numbers Using Recursion

How to write a C Program To Calculate First Numbers Using Recursion in C Programming Language ?

Solution For C Program :

/*C Program To Calculate First Numbers Using Recursion*/

#include<stdio.h>
void main()
{
int sum(int);
int n;
printf("\nEnter Any Number : ");
scanf("%d", &n);
printf("\nSum of N values in the Series is : %d.", sum(n));
}
int sum(int x)
{
int a, b;
if(x == 0) return (0);
if(x == 1) return (1);
a = x - 1;
b = x + sum(a);
return(b);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to Calculation of One Number Raised to Another

How to write a C Program to Calculation of One Number Raised to Another in C Programming Language ?

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another. 


  1. #include<stdio.h>
  2. main()
  3. {
  4. int num1, index, result, temp; /* num2=index*/
  5.  
  6. printf("Enter the number:");
  7. scanf ("%d", &num1);
  8.  
  9. printf("Enter the index:");
  10. scanf("%d", &index);
  11.  
  12. result=1;
  13. temp=1;
  14.  
  15. while(temp<=index)
  16.  
  17. {
  18. result = result*num1;
  19.  
  20. temp++;
  21.  
  22. }
  23.  
  24. printf("%d raised to %d is: %d ", num1, index, result);
  25.  
  26. }


Another C Program to Calculation of One Number Raised to Another:



  1. #include
  2.  
  3. main()
  4. {
  5. int i,n,res;
  6. printf("Enter the Num:");
  7. scanf("%d", &n);
  8. printf("Enter the index:");
  9. scanf("%d", &i);
  10. res=pow(n,i);
  11. printf("The number " %" raised to the power " %"is "%"==" %d, n,i,res );
  12. }
  13. }

C Program to Calculation of One Number Raised to Another:


  1. #include
  2. main()
  3. {
  4. int a,b,c,d;
  5. printf("Enter two numbers separated by space: ");
  6. scanf("%d%d",&a,&b);
  7. = pow(a,b);
  8. printf("The value of, %d raised to the power of %d is %d",a,b,c);
  9. }

C Program to calculate TT and Recharge Amount

How to Write a C Program to calculate Talk time (TT) and Recharge Amount in C Programming Language ?

Calculate Talk time and Recharge amount.
Being 9.3% tax of TRAI for telecom service provider you can calculate Your talk time and recharge amount

1. For Conversation Recharge Amount to talk time
2. For Conversation Talk time to recharge amount

Solution:

  1. #include <stdio.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5.  int ch;
  6.  float a,d,b,c,e,f;
  7.  clrscr();
  8.  printf("\t\t\t Calculate Talk time and Recharge amount\nBeing 9.3% tax of TRAI for telecom service provider you can calculate Your talk time and recharge amount");
  9.  printf("\n 1. For Conversation Recharge Amount to talk time\n2. For Conversation Talktime to recharge amount");
  10.  printf("\n\n Please Enter your choice: ");
  11.  scanf("%d",&ch);
  12.  switch(ch)
  13.  {
  14.   case 1:
  15.   {
  16.    printf("\nYou chosing opt. %d and your opt. is conversation Recharge Amt. to TT\nPlease Enter for calculation",ch);
  17.    getch();
  18.    clrscr();
  19.    printf("\nPlease enter your recharge amount:  ");
  20.    scanf("%f",&a);
  21.    printf("\nPlease Enter processing fee: ");
  22.    scanf("%f",&b);
  23.    printf("\nPlease Enter extra charge: ");
  24.    scanf("%f",&c);
  25.    d=a*0.093;
  26.    e=a-d;
  27.    f=e-b-c;
  28.    printf("\nYour Entered amount is: %.f\n\nYour processing fee is %.f\n\nService Tax= %.2f\n\nYour total talk time(deduction of your service tax only)= %.2f\n\nTotal Talk Time(Deduction of all tax)= %.2f Rupees",a,b,d,e,f);
  29.    break;
  30.   }
  31.   case 2:
  32.   {
  33.    printf("\n You chosing opt. %d and your opt. is conversation TT to Rec. Amt.\nPlease Enter for calculation",ch);
  34.    getch();
  35.    clrscr();
  36.    printf("\nEnter your Talktime: ");
  37.    scanf("%f",&a);
  38.    printf("\nPlease enter Procesing fee: ");
  39.    scanf("%f",&b);
  40.    printf("\nPlease enter all taxes: ");
  41.    scanf("%f",&c);
  42.    d=b+c;
  43.    e=a+d;
  44.    f=(e/(1-0.093));
  45.    printf("\nYour Talk Time(included of all taxes): %.2f\n\nFor getting your given Talk Time you must rechage equal or above= %.f Rupees",a,f);
  46.    break;
  47.   }
  48.   default:
  49.   {
  50.    printf("\nInvalid Choice!!");
  51.   }
  52.  }
  53.  getch();
  54. }