Compile and run the code below in your own C environment.
#include <stdio.h>
int main(void)
{
int N, i, fact;
for (N=1; N<=10; N++)
fact = 1;
for (i=1; i<=N; i++)
fact = fact*i;
printf("%d! = %d\n", N, fact);
return(0);
}
Compile and run the code below in your own C environment.
#include <stdio.h>
int main(void) {
int a = 10;
int b = 3;
int c;
int okay = 1;
char op = '+';
switch(op) {
case '+':
c = a+b;
case '-':
c = a-b;
case '*':
c = a*b;
case '%':
c = a%b;
case '/':
c = a/b;
default:
printf("Unknown operator.\n");
okay = 0;
c = 0;
}
if (okay) printf("\n%d %c %d = %d\n", a, op, b, c);
return(0);
}