Advertisements

Search results for const

Example:[1]

            What is the output of the following program?
#include <stdio.h>
int main()
{
	const int array[5] = {0,1,2,3};
	for(int i = 0;i < 4;i++)
	{
		array[i] += 1;
		printf("%d\n", array[i]);	
	}
}

          
Option A:

            1,2,3,4
            
Option B:

            0,1,2,3
            
Option C:

            2,3,4,5
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[2]

            What is the output of the following program?
#include <stdio.h>  
void main(void) 
{ 
    int i = 10;    
    const int *ptr = &i;        
    *ptr = 100; 
    printf("%d,%d\n", i,*ptr); 
} 
          
Option A:

            100,100
            
Option B:

            110,110
            
Option C:

            100,110
            
Option D:

            Compile error
            
Correct Answer: option D

 Search Links


 Popular C search MCQs


 Popular C search examples