Problem Solving Through Programming In C | NPTEL 2023 | Week 8 Assignment Solutions
ABOUT THE COURSE :
This course is aimed at enabling the students to
- Translate the algorithms to programs (in C language)
- Formulate simple algorithms for arithmetic and logical problems
- Test and execute the programs and correct syntax and logical errors
- Implement conditional branching, iteration and recursion
- Decompose a problem into functions and synthesize a complete program using divide and conquer approach
- Use arrays, pointers and structures to formulate algorithms and programs
- Apply programming to solve matrix addition and multiplication problems and searching and sorting problems
- 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 8 Programming Assignment 1 :-
Week 8 Programming Assignment 1
int HCF(int p, int q)
{
while (p != q)
{
if (p > q)
{
return HCF(p - q, q);
}
else
{
return HCF(p, q - p);
}
}
return(p);
}
Week 8 Programming Assignment 2 :-
Week 8 Programming Assignment 2
long power(int n, int p)
{
if (p)
{
return (n * power(n, p - 1));
}
return(1);
}
Week 8 Programming Assignment 3 :-
Week 8 Programming Assignment 3
int binary_conversion(int number3)
{
if (number3 == 0)
{
return 0;
}
else
{
return (number3 % 2) + 10 * binary_conversion(number3 / 2);
}
}
Week 8 Programming Assignment 4 :-
Week 8 Programming Assignment 4
int q, t;
int num = 2;
for (q = 0; q < lines; q++)
{
for (t = 0; t <= q; t++)
{
while (!prime(num))
{
num++;
}
printf("%d\t", num++);
}
printf("\n");
}
return (0);
}
int prime(int num)
{
int q, flag;
for (q = 2; q < num; q++)
{
if (num % q != 0)
flag = 1;
else {
flag = 0;
break;
}
}
if (flag == 1 || num == 2)
return (1);
else
return (0);
} 
Follow Us