Code Tantra
Code Tantra
sNo=1&qId=619c8e11b47b1206501f2199&bd=AMjc0X2N0X2No&lid=624d781…
S.No: 1 Exp. Name: Write a program to initialize array and traverse. Date: 2022-04-25
Aim:
Page No:
Write a C Program to implement initialisation of array and traversal operation.
Source Code:
ID: B21ME015
array.c
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
int main()
{
int a[]={1,3,5,2,8,9,7,6,0,4};
int n, size, i;
size=sizeof(a);
n=size/sizeof(int);
printf("There are %d elements in the array\n",n);
printf("Elements in forward direction\n");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
printf("\nElements in backward direction\n");
for(i=n-1;i>=0;i--)
{
printf("%d\t",a[i]);
}
return 0;
}
2021-2025-MECH-1
Test Case - 1
User Output
Enter how many values you want to read : 5
Enter the value of a[0] : 23
Enter the value of a[1] : 63
Kakatiya Institute of Technology and Science
https://kitsw.codetantra.com/secure/labs-q.jsp?sNo=1&qId=619c8e11b47b1206501f2199&bd=AMjc0X2N0X2No&lid=624d7816232d4a06d607281… 1/1