Quick Tip: How to read an array in C

Because this is something that you should really know. And because I did not tell you this in my previous tutorials, I made this quick tip to show you how to read an array in C.

#include "stdafx.h"
#include <stdio.h>

int main()
{
	int a[10],i;

	for(i = 0; i < 10; i++)
	{
		printf("a[%d]:",i);
		scanf("%d",&a[i]);
	}

	for(i = 0; i < 10; i++)
	{
		printf("a[%d]: %d",i,a[i]);
	}
	getchar();

}

Leave a Reply

Your email address will not be published. Required fields are marked *


*

WordPress SEO