Wrong Output. Whats the problem with my program?
Objective: Write a program in C that uses array to store the telephone no. of students against their roll no. Input a roll no, and then search the array for the student's telephone number.
Code:
#include<stdio.h>
void main()
{
int arr[3][1];
int i,j,k=100,roll;
for(i=0,j=0; i<3; i++)
{
arr[i][j]=k;
k++;
}
for(i=0,j=1; i<3; i++)
{
printf("\nEnter Phone no. Against Roll no. %d: ", arr[i][j]);
scanf("%d", &arr[i][j]);
}
printf("\nEnter Roll no. ");
scanf("%d", &roll);
for(i=0,j=0; i<3; i++)
{
if(roll==arr[i][j])
{
for(i=0,j=1; i<3; i++)
printf("Phone No. %d", arr[i][j]);
}
}
}