//-----------------------------------------------------------------------------
// short_demoII.c
//
// some small code snips
// demonstrating the use of if, case, and ternaer
//
// group: group 1,13 study assistant AltiHar
//
// author: Altinger Harald 0630xxx
//
// last change: created all (Altinger Harald)
//-----------------------------------------------------------------------------
//

#include <stdio.h>

//----------------------------------------------------------------------------- 
/// 
/// The main program. 
///
/// print different excamples, demonstrating logical programming mistakes
/// 
///  @return int  always zero 
// 
int main()
{
  int a_number = 1;
  int count;
  int count2;
  
  //think about maths!
  printf("------comperators-----\n");
  if (a_number > 1)
    printf("var. biger than 1\n");
    
  if (a_number >= 1)
    printf("var. bigger or equal 1\n");
  else
    printf("var. not bigger or equal 1\n"); 
  printf("hallo\n"); //not a part of the if/else block!
  
  printf("--ternaer operator:---\n");
  a_number > 0 ? printf("var. is pos\n") : printf("var. is neg or 0\n");   
  
  printf("--same as if / else:--\n");
  if(a_number > 0)
  {
    printf("var. is pos\n");
  }
  else
  {
    printf("var. is neg or 0\n");
  }
  
  //two loops connected
  printf("---------for:---------\n");  
  for(count = 10; count > 4; count--)
 {
      for(count2 = 0; count2 < count; count2++)
        printf("+");
        printf("\n");  //part of first loop!
    }
  
  printf("---------for:---------\n");
  //access the count variable within loop  
  for(; count > 0; count--) //not nice!
 {
      for(count2 = 0; count2 < 3; count2++)
      {
        printf("*");
      }
      printf("\n"); //part of first loop!
      count -= 1;   //access outer loop count variable
    }  
  
  //same with while
  printf("--------while:--------\n");  
  count = 3;
  while(count > 0)
    {
      count--; //meand count = count - 1
      for(count2 = 0; count2 < 3 - count; count2++)
      {
        printf("-");
      }
      printf("\n"); //part of first loop!
      count -= 1;   //access loop count variable
    } 
	  
  return 0;
}

