11 November 2022

Array

 

Array:

 

#include<stdio.h>

#include<conio.h>

 

void main()

{

                int i, no[10];

                clrscr();

                printf(“Enter values in an array”);

                printf(“--------------------------------“);

 

                // Input/ Scan the numbers

                for(i=0; i<10; i++)

                {

                printf(“Enter value %d”, i+1);

                scanf(“%d”, &no[i]);

}

 

// Output/ Print the numbers

for(i=0; i<10; i++)

                {

                printf(“Value %d is %d”, i+1, no[i]);         

}

                getch();

}

 

 

Exercise:

1. Define an array of 5 employee. Enter the id number of 5 employee and print it.

2. Define an array of 5 students. Enter the percentage of 5 studnets and print it.

 

No comments:

Post a Comment