0% found this document useful (0 votes)
8 views

Code Tantra

The document outlines a C program designed to initialize an array and perform traversal operations. It includes source code that demonstrates how to display array elements in both forward and backward directions. The execution results confirm that all test cases have succeeded, showcasing user input and output for the array elements.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Code Tantra

The document outlines a C program designed to initialize an array and perform traversal operations. It includes source code that demonstrates how to display array elements in both forward and backward directions. The execution results confirm that all test cases have succeeded, showcasing user input and output for the array elements.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

6/5/22, 7:06 PM https://kitsw.codetantra.com/secure/labs-q.jsp?

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;
}

Execution Results - All test cases have succeeded!

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

Enter the value of a[2] : 45


Enter the value of a[3] : 12
Enter the value of a[4] : 20
The array elements are : 23 63 45 12 20
Elements in backward direction: 20 12 45 63 23

https://kitsw.codetantra.com/secure/labs-q.jsp?sNo=1&qId=619c8e11b47b1206501f2199&bd=AMjc0X2N0X2No&lid=624d7816232d4a06d607281… 1/1

You might also like