Chapter - 9: Arrays

What would be the output of the following programs:


A
Sections
1
Exercises

(a)

#include<stdio.h>
int main()
{
	int num[26], temp;
	num[0] = 100;
	num[25] = 200;
	temp = num[25];
	num[25] = num[0];
	num[0] = temp;
	printf("\n%d %d", num[0], num[25]);
	return 0;
}

Output: 200 100


(b)

#include<stdio.h>
int main()
{
	int array[26], i;
	for (i = 0; i <= 25; i++)
	{
		array[i] = 'A' + i;
		printf("\n%d %c", array[i], array[i]);
	}
	return 0;
}

Output: ASCII Value Table


(c)

#include<stdio.h>
int main()
{
	int sub[50], i;
	for (i = 0; i <= 48; i++);
	{
		sub[i] = i;
		printf("\n%d", sub[i]);
	}
	return 0;
}

Output: 49


© 2020 Garbage Valuegarbage value logo