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();

}

Author: Horațiu Condrea

My name is Horațiu Condrea, and I work as a Software Developer Manager at Siemens PLM Software. I hope that my experiments will prove to be useful for many of you guys/girls out there. Don’t forget to leave a comment whenever you run over a bug or something that is not working as it should be. For any kind of information contact me.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.