c++ enum as srting code example
Example 1: how to use a pointer as a parameter in c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void add(int* a, int* b, int* c)
{
*c = *a + *b;
}
int main()
{
int a, b, c;
a = 3;
b = 5;
add(&a, &b, &c);
printf("%d", c);
}
Example 2: a enum data type in c with loop
// example program to demonstrate working
// of enum in C
#include<stdio.h>
enum year{Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec};
int main()
{
int i;
for (i=Jan; i<=Dec; i++)
printf("%d ", i);
return 0;
}
// OUTPUT
0 1 2 3 4 5 6 7 8 9 10 11