Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://pastebin.com/u/TheWhiteFang
- // Tut01.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- int main() {
- int x = 2;
- switch(x)
- {
- case 2:
- printf("Two\n");
- break; //no break
- case 3:
- printf("Three\n");
- break;
- }
- return 0;
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- // Tut01.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- int main() {
- int x = 4;
- if ( x == 6 ) //==
- {
- printf("x equals 6\n");
- }
- return 0;
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- // Tut01.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- int main() {
- for (int i=100; i>=0;i-=3) // i>=0
- {
- printf("i equals %d\n", i);
- }
- return 0;
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- // Tut01.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- int main() {
- double halfval=1.0/2.0; //1.0 and 2.0
- printf( "Halfval %g\n",halfval); //%g or %lf
- return 0;
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- // Tut01.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- int main() {
- char st1[] = "abc";
- char st2[] = "abc";
- if ( st1 == st2 ) //address compared not chararray
- {
- printf("Yes\n");
- }
- else
- {
- printf("No\n");
- }
- return 0;
- }
- -----
- int a, intArray[5];
- for (a=0 ; a <= 10 ; a++)
- intArray[a] = a * 2;
- int x;
- char st[31];
- printf("Enter an integer: ");
- scanf(%d, &x); //unflushed somth
- printf("Enter a line of text: ");
- fgets(st, 31, stdin);
- -----
- //skipped declar int test
- ----
- 010; //octal casting
- ----
- -5 10 5 9 6 99 1000 85 5000 -50 -100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement