title: Segmentation fault core dumped...?
body: <p>I'm trying to accomplish this:</p>
  
  <blockquote>
    <blockquote>
      <p>Write a program that accepts three user inputs: assignment mark, midterm mark, and final exam
         mark.<p> These inputs are of type float and should have values between 0 and 100.<p> The program
        should compute the final grade as a percentage and a letter grade.<p>
      • Final grades are computed as: Assignments 20%, Midterm 30%, Final exam 50%. Letter grades
         are computed as: A (final grade ≥ 80%), B (80 > final grade ≥ 70%), C (70 > final grade ≥ 60%),
              D (60 > final grade ≥ 50%), and F (50 > final grade).<p>
      The final grade and letter grade are displayed.</p>
    </blockquote>
  </blockquote>
  
  <p>with the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int checkMark(int);
  float getMark();
  float computeFinalGrade(float assign, float midterm, float finalExam, float finalGrade);
  int computeLetterGrade(float);
  
  int checkMark(int x)
  {
      while(x&lt;0 || x&gt;100) //While x is a negative number:
      {
          printf("Invalid entry.Try again:");
          scanf("%d",&amp;x);
      }
  
      if(x&gt;0 &amp;&amp; x&lt;=100)//If x is a positive number:
          x=x;
  
      return x;
  }
  
  float getMark(void)
  {
      float mark=0,assignMark=0,midMark=0,examMark=0,finalMark=0;
      char letterGrade;
  
  
      printf("Enter assignment grade:");
      scanf("%d",mark);
  
      checkMark(mark);
      assignMark=mark;
  
      printf("\nEnter midterm mark:");
      scanf("%f",&amp;mark);
  
      checkMark(mark);
      midMark=mark;
  
      printf("\nEnter exam mark:");
      scanf("%f",&amp;mark);
  
      checkMark(mark);
      examMark=mark;
  
  
      finalMark=computeFinalGrade(assignMark,midMark,examMark,finalMark);
      letterGrade=computeLetterGrade(finalMark);
  
      printf("The final grade for the course is %.1f, and the letter grade is %c.\n",finalMark,letterGrade);
  
      return 0;
  }
  
  float computeFinalGrade(float assign, float midterm, float finalExam, float finalGrade)
  {
      assign=(float)0.2*assign;
      midterm=(float)0.3*midterm;
      finalExam=(float)0.4*finalExam;
  
      finalGrade=(float)assign+midterm+finalExam;
      return finalGrade;
  }
  
  int computeLetterGrade(float finalGrade)
  {
      int grade;
  
          if(finalGrade&gt;=80)
              grade=65;
  
          if(finalGrade&lt;80)
              if(finalGrade&gt;=70)
                  grade=66;
  
          if(finalGrade&lt;70)
              if(finalGrade&gt;=60)
                  grade=67;
  
          if(finalGrade&lt;60)
              if(finalGrade&gt;=50)
                  grade=68;
  
          if(finalGrade&lt;50)
              grade=70;
  
      return grade;
  }
  
  int main()
  {
      getMark();
  
      return 0;
  }
  </code></pre>
  
  <p>When I debug the program above and enter a negative number it gives me this:</p>
  
  <pre><code>Enter assignment grade:123
  Segmentation fault (core dumped)
  </code></pre>
  
  <p>What am I doing wrong exactly?</p>