<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jetzt lerne ich Programmieren! &#187; variablen</title>
	<atom:link href="http://www.jlip.de/tag/variablen/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jlip.de</link>
	<description>oder so ähnlich</description>
	<lastBuildDate>Thu, 22 Apr 2010 14:58:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Übung zu Variablen</title>
		<link>http://www.jlip.de/c/ubung-zu-variablen/</link>
		<comments>http://www.jlip.de/c/ubung-zu-variablen/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 14:29:15 +0000</pubDate>
		<dc:creator>Harun (admin)</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[einlesen]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[variablen]]></category>

		<guid isPermaLink="false">http://www.jlip.de/?p=196</guid>
		<description><![CDATA[Heute gibt es eine Übung zu den Variablen, damit es richtig sitzt.
Alles soll durch ein Programm realisiert werden.
1. Eine Char-Variable einlesen (Zahl, Zeichen oder Sonderzeichen), dann als Zeichen UND als Zahl ausgeben.
2. Hintereinander 3 int Variablen einlesen. Danach erst die zweite dann die erste dann dritte Variable ausgeben.
3. Eine Kommazahl mit Float einlesen dann, als [...]]]></description>
			<content:encoded><![CDATA[<p>Heute gibt es eine Übung zu den Variablen, damit es richtig sitzt.<br />
Alles soll durch ein Programm realisiert werden.</p>
<p>1. Eine Char-Variable einlesen (Zahl, Zeichen oder Sonderzeichen), dann als Zeichen UND als Zahl ausgeben.<br />
2. Hintereinander 3 int Variablen einlesen. Danach erst die zweite dann die erste dann dritte Variable ausgeben.<br />
3. Eine Kommazahl mit Float einlesen dann, als Datentyp: g, f und e ausgeben.<br />
4. double einlesen dann als Datentyp: g,f,e ausgeben.</p>
<p>Die Lösung steht unten:</p>
<p><span id="more-196"></span></p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<pre class="cpp"><span style="color: #ff0000;">// Übung zu den Variablen</span>
&nbsp;
<span style="color: #339900;">#include</span>
<span style="color: #339900;">#include </span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #ff0000;">// Aufgabe 1</span>
 <span style="color: #0000ff;">char</span> zeichen;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Bitte ein Zeichen eingeben<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%c&quot;</span>,&amp;zeichen<span style="color: #000000;">&#41;</span>;                    <span style="color: #ff0000;">// liest das Zeichen in die Variable &quot;zeichen&quot; ein</span>
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Du hast %c eingegeben<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, zeichen<span style="color: #000000;">&#41;</span>; <span style="color: #ff0000;">// Ausgabe der Variable &quot;zeichen&quot;</span>
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Als Zahl ergibt das %i im ASCII CODE<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, zeichen<span style="color: #000000;">&#41;</span>;  <span style="color: #ff0000;">// Ausgabe als ASCII Code</span>
&nbsp;
<span style="color: #ff0000;">// Aufgabe 2  ------------------------------------------------------------------------------</span>
 <span style="color: #0000ff;">int</span> zahl1;
 <span style="color: #0000ff;">int</span> zahl2;
 <span style="color: #0000ff;">int</span> zahl3;
&nbsp;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Gib deine erste Zahl ein<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>,&amp;zahl1<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Gib deine zweite Zahl ein<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>,&amp;zahl2<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Gib deine dritte Zahl ein<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>,&amp;zahl3<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Die Zweite Zahl war %i deine erste %i und deine dritte %i<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, zahl2,zahl1,zahl3<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #ff0000;">// Aufgabe 3 -------------------------------------------------------------------------------</span>
 <span style="color: #0000ff;">float</span> kommazahl;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Gib deine Kommazahl ein<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%f&quot;</span>,&amp;kommazahl<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Variable im Format g: %g<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, kommazahl<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Variable im Format f: %f<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, kommazahl<span style="color: #000000;">&#41;</span>;
 <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Variable im Format e: %e<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, kommazahl<span style="color: #000000;">&#41;</span>; 
&nbsp;
<span style="color: #ff0000;">// Aufgabe 4 ----------------------------------------------------------------------------</span>
&nbsp;
 <span style="color: #0000ff;">double</span> blabla;
&nbsp;
  <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Gib deine double Zahl ein<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
  <span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%lf&quot;</span>,&amp;blabla<span style="color: #000000;">&#41;</span>;
  <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;dein double im Format g: %g<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, blabla<span style="color: #000000;">&#41;</span>;
  <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;dein double im Format f: %f<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, blabla<span style="color: #000000;">&#41;</span>;
  <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;dein double im Format e: %e<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span>, blabla<span style="color: #000000;">&#41;</span>; 
&nbsp;
<span style="color: #ff0000;">// ENDE</span>
&nbsp;
<span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Glückwunsch du hast es geschafft.... nun kannste schlafen gehen&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
 getch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jlip.de/c/ubung-zu-variablen/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Einlesen und ausgeben von Variablen mit scanf</title>
		<link>http://www.jlip.de/c/einlesen-und-ausgeben-von-variablen-mit-scanf/</link>
		<comments>http://www.jlip.de/c/einlesen-und-ausgeben-von-variablen-mit-scanf/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 11:02:58 +0000</pubDate>
		<dc:creator>Harun (admin)</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[einlesen]]></category>
		<category><![CDATA[scanf]]></category>
		<category><![CDATA[variablen]]></category>

		<guid isPermaLink="false">http://www.jlip.de/?p=145</guid>
		<description><![CDATA[Einlesen
Mit dem Befehl scanf wartet das Programm auf eine Eingabe über die Tastatur. Diese Eingabe kann man wiederrum in eine Variable abspeichern und später dann aufrufen. Bevor man aber etwas eingeben kann, muss man den genauen Datentyp bekannt machen.
Beispiel:
scanf&#40;&#34;%i&#34;, &#38;k&#41;;   /* Liest in die int-Variable k ein.
Zuerst den Datentyp bestimmen danach die Variable angeben */
&#160;
scanf&#40;&#34;%i&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Einlesen</strong></p>
<p>Mit dem Befehl <a href="http://hackedgadgets.com/2009/09/04/printf-and-scanf-examples-for-microcontrollers/trackback/">scanf</a> wartet das Programm auf eine Eingabe über die Tastatur. Diese Eingabe kann man wiederrum in eine Variable abspeichern und später dann aufrufen. Bevor man aber etwas eingeben kann, muss man den genauen Datentyp bekannt machen.<span id="more-145"></span></p>
<p>Beispiel:</p>
<pre class="cpp"><span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>, &amp;k<span style="color: #000000;">&#41;</span>;   <span style="color: #ff0000; font-style: italic;">/* Liest in die int-Variable k ein.
Zuerst den Datentyp bestimmen danach die Variable angeben */</span>
&nbsp;
<span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>, &amp;c<span style="color: #000000;">&#41;</span>;  <span style="color: #ff0000; font-style: italic;">/* Liest in die int-Variable c ein */</span></pre>
<p><strong>Ausgeben</strong></p>
<p>Da wir nun durch eine Eingabe eine Zahl in den Variablen k und c gespeichert haben, könne wir sie durch eine Bildschirmausgabe aufrufen. Wir können sie auch addieren, multiplizieren usw. aber das kommt später <img src='http://www.jlip.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Genau wie scanf muss auch printf  den Datentyp kennen welchen ausgegeben soll.</p>
<p>Beispiel:</p>
<pre class="cpp"><span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Du hast die Zahl %i eingegeben&quot;</span>, k<span style="color: #000000;">&#41;</span>;  <span style="color: #ff0000; font-style: italic;">/* Man schreibt
den Datentyp rein und am Schluss die Variable die man dort haben
möchte */</span></pre>
<p>Komplett-Programm:</p>
<pre class="cpp"><span style="color: #339900;">#include</span>
<span style="color: #339900;">#include </span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0000ff;">int</span> zahl1;
<span style="color: #0000ff;">int</span> zahl2;
&nbsp;
<span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Wie alt bist du?<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>, &amp;zahl1<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Und wie alt ist deine Mutter?<span style="color: #666666; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0000dd;">scanf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;%i&quot;</span>, &amp;zahl2<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #666666; font-weight: bold;">\n</span>Wie ich es vestanden habe bist du %i und deine Mutter ist  %i&quot;</span>, zahl1, zahl2<span style="color: #000000;">&#41;</span>;
getch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jlip.de/c/einlesen-und-ausgeben-von-variablen-mit-scanf/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
