Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Halli hallo

Kurze Frage, steh grade bissle aufm Schlauch....

Wie kann ich in C die letzte Ziffer einer Zahl unterschiedlichen Typs bestimmen.

also unsigned long zahl1 = 312423 --> 3

unsigned int zahl 2 = 12345 --> 5

Danke schonmal

Gruss

Für ganzzahlige Zahlen:

int LetzteZiffer = Zahl % 10;

gleiche lösung, nur umständlicher ^^


int blubb = 1234567;
int b2;

b2 = blubb/10;

printf("--> %d\n", blubb - (b2*10));
[/PHP]

Danke,

hilft mir enorm weiter

Aber noch ne Frage, was ist wenn ich die zweitletzte Ziffer möchte ? oder die erste Ziffer ? oder die Anzahl der Ziffern ? da komme ich mit dem mod Operator nicht arg weit....

danke

Dann kombiniert man die 2 Operatoren Div (/ in C) und Mod (% in C)

Div=Ganzzahlige Division (Division ohne Rest), Modulo berechnet den Rest einer Division

2. letzte Stelle einer Zahl -> (Zahl/10)%10

1. Stelle einer Zahl: solange Zahl/10>0 mache zahl=zahl/10

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.