Location: NT-LAB PROGRAMS

Discussion: Sending the program for OSPF------PART 1Reported This is a featured thread

Showing 1 post

Posted Anonymously
Sending the program for OSPF------PART 1
Apr 9 2007, 3:33 PM EDT | Post edited: Apr 9 2007, 3:33 PM EDT
Sending the program for OSPF(Output just displays all
shortest path routes in the network)
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num=0,rinfo[81],sum=0,cnt=0,hop[81],cost[81],router[81],temp=0;
cout<<"How Many Routers Between Source And Destination other than router 1???\n";
cin>>num;
cout<<"Enter Router Details\n";
for(int i=0;i<num;i++)
{
cout<<"To how many routers is router\t"<<i+1<<"connected?";
cin>>rinfo[i];
sum=sum+rinfo[i];
if(sum>num+1)
{
cout<<"Error In Network Config...\n";
break;
}
}
cout<<"Enter the next hop no. and the cost between the connected routers\n";
int j=0;
for(i=0;i<num;i++)
{
cnt=1;
while(cnt<=rinfo[i])
{
router[j]=i+1;
cout<<"Enter the Next Hop!\n";
cin>>hop[j];
cout<<"Enter the cost Between Routers"<<i+1<<"And"<<hop[j]<<" : ";
cin>>cost[j];
cnt++;
j++;
}
}
cout<<"Router DataBase\n";
cout<<"Router No.\tcost\tNext Hop\n\n";
j=0;
for(i=0;i<num;i++)
{
cnt=1;
while(cnt<=rinfo[i])
{
cout<<i+1<<"\t"<<hop[j]<<"\t"<<cost[j]<<endl;
cnt++;
j++;
}
}
Do you find this valuable?    
Keyword tags: None (edit keyword tags)

Be the first to reply.