Problem Solving Through Programming In C | NPTEL 2023 | Week 4 Assignment Solutions

ABOUT THE COURSE :
Week 4

This course is aimed at enabling the students to
  1. Translate the algorithms to programs (in C language)
  2. Formulate simple algorithms for arithmetic and logical problems
  3. Test and execute the programs and correct syntax and logical errors
  4. Implement conditional branching, iteration and recursion
  5. Decompose a problem into functions and synthesize a complete program using divide and conquer approach
  6. Use arrays, pointers and structures to formulate algorithms and programs
  7. Apply programming to solve matrix addition and multiplication problems and searching and sorting problems 
  8. Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration

Course Status     :    Upcoming
Course Type        :    Elective
Duration               :    12 weeks
Start Date            :    23 Jan 2023
End Date              :    14 Apr 2023
Exam Date           :    29 Apr 2023 IST
Enrollment Ends :    06 Feb 2023

CRITERIA TO GET A CERTIFICATE :

Average assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

NOTE: Please note that there will not be an unproctored programming exam for this course this term.

Week 4 Programming Assignment 1 :-

Week 4 Programming Assignment 1
if (n2>n1)
{
  if(n1 < n3)
  printf("%d is the smallest number.", n1);
 else
 printf("%d is the smallest number.", n3);
}
else
 {
     if(n2 < n3)
     printf("%d is the smallest number.", n2);
     else
     printf("%d is the smallest number.", n3);
}
}

Week 4 Programming Assignment 2 :-

Week 4 Programming Assignment 2
fact=1;
   for(int i=n;i>0;i--)
   {
     fact*=i;
   }

printf("The Factorial of %d is : %ld",n,fact);

}

Week 4 Programming Assignment 3 :-

Week 4 Programming Assignment 3
for(int i=2;i<=N;i++)
{
  if(i%2==0)
  sum+=i;
}
printf("Sum = %d", sum);
}

Week 4 Programming Assignment 4 :-
Week 4 Programming Assignment 4
Last_digit =N%10;
 while(N>0)
 {
   First_digit=N%10;
   N/=10;
 }

Join us :