Write a C program to Control Statement Structure.

Function Main
    Declare Integer k
    Assign k = 1
    If k=1
        Output "t"
    End
    If k=0
        Output "F"
    Else
        Output "!f"
    End
    For k = 0 to 3
        Output ""&k
    End
    While k<5
        Output ""&k
        Assign k = k+1
    End
    Loop
        Assign k = k+1
        Output ""&k
    Do k<7
End

#include <stdio.h>
int main() {
  int k;
  if (1) {
    printf("t");
  }
  if (0) {
    printf("F");
  } else {
    printf("!f");
  }
  for (k = 0; k <= 3; k++) {
    printf("%i", k);
  }
  while (k < 5) {
    printf("%i", k);
    ++k;
  }
  do {
    printf("%i", k);
    k += 1;
  } while (k < 7);
}

t!f0123467

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.