Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Lab 12

1. List out all the available storage class in C.

2. What is automatic about an automatic variable?

3. Differentiate between global and local variables.

4. Explain the use of register.

5. What will be the output for the following program.

#include <stdio.h>
#define MAXNUM 3
 
void sum_up(void);
 
int main()
{
    int count;
    
    printf("\n*****static storage*****\n");
    printf("Key in 3 numbers to be summed ");

    for(count = 0; count < MAXNUM; count++) /* count = 0, 1, 2 */


        sum_up();

    printf("\n*****COMPLETED*****\n");
    return 0;
}
 
void sum_up(void)
{
    static int sum = 0;
    int num;
   
    printf("\nEnter a number: ");
    scanf("%d", &num);
    sum += num;
    printf("\nThe current total is: %d\n", sum);
}

You might also like