Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7784781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:09:00+00:00 2026-06-01T20:09:00+00:00

I was writing this code for FCFS scheduling. But in Linux this is giving

  • 0

I was writing this code for FCFS scheduling. But in Linux this is giving
“Segmentation error”. How to correct such error?

 #include<stdio.h>
#include<string.h>
float fxn();

int main()
{

float avgwt;
int n,i,at[10],bt[10];
printf("\n\nEnter the number of processes:");
scanf("%d",&n);
printf("\n\n BURST TIME and ARRIVAL TIME of thr process");
for(i=0;i<n;i++)
{
printf("\n ARRIVAL TIME :");
scanf("%d",&at[i]);
printf(" BURST TIME : ");
scanf("%d",&bt[i]);
}

avgwt=fxn(at,bt,n);

printf("\n\nAverage waiting time=%f",avgwt);
return 0;

}



float fxn( int at[], int bt[], int n)

{

int i,j,t,wt[n],sum,tt[n],q;

float avgwt;


 for(j=i+1;j<n;j++)
  {
   if(at[i]>at[j])

    {
t=at[i];
at[i]=at[j];
at[j]=t;
q=bt[i];
bt[i]=bt[j];
bt[j]=q;
    }
   }


wt[0]=0;


for(i=0;i<n;i++)
{

wt[i+1]=wt[i]+bt[i];
sum=sum+(wt[i+1]-at[i]);

}

avgwt=sum/n;

return avgwt;


}

Another Question —- I will be editing this code for making a system call in linux.

Will the passing of arrays will work if a c program will takes input from user and passes it to the kernel for further calculations?

(for example – here main() function for taking input and fxn() function into the kernel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:09:01+00:00Added an answer on June 1, 2026 at 8:09 pm

    You got a buffer overflow below

    for(i=0;i<n;i++)
    {
    
      wt[i+1]=wt[i]+bt[i];
       sum=sum+(wt[i+1]-at[i]);
      } 
    

    it should be i < n -1 also you need to intialize i=0 in function fxn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing this code that one function calls itself recursively. But I am
I was writing this code on codeblocks(only compiler I m having).When I encountered such
I have some file writing code that works as expected, but prints an error
I was writing this code in C when I encountered the following problem. #include
I was writing this code: public static void main(String[] args) { double g =
jQuery('img').bind('error',function(){ alert('hi'); jQuery(this).hide(); }); I have written this code but non available images are
I was writing this code in C++ and it kept giving me an answer
I have nearly finished writing this code: http://jsfiddle.net/2Jkk9/11/ but I can't figure out how
I've tried writing this code from scratch, coding, and running it but it just
I'm writing this code for an extension but It returns: Origin chrome-extension://gjganecebobheilkbpmhmocibjckgidc is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.