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

hi,

ich schreibe morgen eine arbeit in c und ich kappiere einfach nicht wie logische operatoren in der funktion printf() funktionieren.

ich habe hier mal eine beispielaufgabe kopiert:

Geben Sie die Programmausgaben der jeweiligen Programmzeile als Kommentar an.

#include <stdio.h>


main() 

{ 

  int i = 5; 

  int j = 11;  

  float e = 2.718281828f; 

  float result; 


  printf( "%x \n" , i & j );      /* Ausgabe:    */ 

  printf( "%x \n" , ~i & j );      /* Ausgabe:    */ 

  printf( "%x \n" , i | j );      /* Ausgabe:    */ 

  printf( "%x \n" , i ^ j );      /* Ausgabe:    */ 

  printf( "%x \n" , i<<2 );      /* Ausgabe:    */ 

  printf( "%d \n" , j%i );      /* Ausgabe:     */ 


  printf( "%d \n" , ((i>>1) ^ j) && i );  /* Ausgabe:     */ 



  result = (int) (e + 0.5f);       

  printf( "%f \n", result );      /* Ausgabe:     */ 


Kann mir bitte jemand helfen?

Bitwise operation - Wikipedia, the free encyclopedia

Es sind einfach Operatoren die Bits auf 1 oder NULL setzen... quasi Rechnungen mit denen macht

Was vielleicht hilf bei dir:

printf( "%x \n" , i & j ); /* Ausgabe: */

i = 5 = 0101 (BIN)

j = 11 = 1011 (BIN)

und das "&" steht für AND siehe http://en.wikipedia.org/wiki/Bitwise_operation#AND

0101

1011

-----

0001 = 1 (DEZ) also 5 & 11 = 1 (DEZ)

Weil eine 1 als Ergebnis nur kommt wenn beide Bits auf 1 stehen

Bearbeitet von fisianer2009

ok danke.

könnt ihr mir bitte die lösung für die aufgaben posten, damit ich mich selbst kontrollieren kann

hm führ das programm doch einfach aus?

Danke fisianer2009 !!! Jetzt habe ich es kappiert

bitte :)

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.