C/Language Basics/Main


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

A for loop inside main function

#include <stdio.h>
int main(void)
{
  int x; 
  for(x = 1; x <= 100; x++) 
      printf("%d ", x);
  return 0;
}


Const function in all c programs: main() function

#include <stdio.h>

int main() {
    puts("program");
    return(0);
}


Display Hello and your name

/* Display Hello and your name */
#include<stdio.h>
void main()
{
  printf("Hello www.java2s.com!");
}


Display Hello: output String

/*Display Hello */
#include <stdio.h>
void main()
{
  printf("Hello");
}


main function

#include <stdio.h>
int main(void)
{
  printf("This is a short C program.");
  return 0;
}


Program starts with main function

#include "stdio.h"
int main(void)
{
  printf("This is a test");
  return 0;
}


Simple string ouput

#include <stdio.h>
int main(void)
{
  printf("hello");
  /* printf("there"); */
  return 0;
}