Saturday, 22 January 2011

c programming examples

Example 1 - C hello world program /* A very simple c program printing a string on screen*/ #include<stdio.h>   main() { printf("Hello World\n"); return 0; } Output of above program: "Hello World" Example 2 - c program to take input from user using scanf #include<stdio.h>   main() { int number;   printf("Enter a number\n"); scanf("%d",&number);   printf("Number entered by you is %d\n", number);   return 0; } Output: Enter a number 5 Number entered by you is 5 Example 3 - using if else control instructions #include<stdio.h>   main() { int x = 1;   if ( x == 1 ) printf("x is equal to one.\n"); else printf("For comparison use == as = is the assignment operator.\n");   return 0; } Output: x...

Search here for "Freshers Jobs"