# NPTEL Problem Solving Through Programming In C WEEK 11 Assignment July 2022 NPTEL Problem solving through Programming In C Week 11 All Programming Assignment Solutions | Swayam 2022. With the growth of Information and Communication Technology, there is a need to develop large and complex software.

This course is aimed at enabling the students to:
• Formulate simple algorithms for arithmetic and logical problems
• Translate the algorithms to programs (in C language)
• 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 LAYOUT
• Week 1 : Introduction to Problem Solving through programs, Flowcharts/Pseudo codes, the compilation process, Syntax and Semantic errors, Variables and Data Types
• Week 2 : Arithmetic expressions, Relational Operations, Logical expressions; Introduction to Conditional Branching
• Week 3 : Conditional Branching and Iterative Loops
• Week 4 : Arranging things : Arrays
• Week 5 : 2-D arrays, Character Arrays and Strings
• Week 6 : Basic Algorithms including Numerical Algorithms
• Week 7 : Functions and Parameter Passing by Value
• Week 8 : Passing Arrays to Functions, Call by Reference
• Week 9 : Recursion
• Week 10 : Structures and Pointers
• Week 11 : Self-Referential Structures and Introduction to Lists
• Week 12 : Advanced Topics

Once again, thanks for your interest in our online courses and certification. Happy learning!

#### Course Name : “Problem Solving through Programming In C 2022”

Program : 1 ```				```
#include<stdio.h>
int main()
{
float t={10,15,18,22,30}, v={22,26,35,48,68};
float a; //Value of the t to find the respective value of v(t)
scanf("%f", &a);
int i,j;
float b, c, k =0;
for(i=0; i<5; i++)
{
b=1;
c=1;
for(j=0; j<5; j++)
{
if(j!=i)
{
b=b*(a-t[j]);
c=c*(t[i]-t[j]);
}
}
k=k+((b/c)*v[i]);
}
printf("The respective value of the variable v is: %.2f", k);
return 0;
}
```
```

#### Course Name : “Problem Solving through Programming In C 2022”

Program : 2 ```				```
#include<stdio.h>
float func(float x);
int main()
{
int n=10; //Taking n=10 sub intervals
float a,b,integral; //integral is the integration result
scanf("%f",&a); // initial limit taken from test case
scanf("%f",&b);
int i;
float h,x, sum=0;
if(b>a)
h=(b-a)/n;
else
h=-(b-a)/n;
for(i=1;i<n;i++)
{
x=a+i*h;
sum=sum+func(x);
}
integral=(h/2)*(func(a)+func(b)+2*sum);
printf("The integral is: %0.6f\n",integral);
return 0;
}

float func(float x)
{
return x*x;
}

```
```

#### Course Name : “Problem Solving through Programming In C 2022”

Program : 3 ```				```
#include <stdio.h>
int checkPrime(int, int); //Function to check prime or not

int main()
{
int num, check;
scanf("%d", &num); //The number is taken from test case data
check = checkPrime(num, num/2);
if (check == 1)
{
printf("%d is a prime number\n", num);
}
else
{
printf("%d is not a prime number\n", num);
}
return 0;
}
int checkPrime(int num, int i)
{
if (i == 1)
return 1;
else
{
if (num % i == 0)
return 0;
else
return checkPrime(num, i - 1);
}
}

```
```

#### Course Name : “Problem Solving through Programming In C 2022”

Program : 4  Write a C program to reverse a word using Recursion. Input to the program is a string that is to be taken from the user and output is reverse of the input word. Note that you have to use recursion.

```				```
#include <stdio.h>
#define MAX 100
char *reverse(char[]);

int main()
{
char str[MAX], *rev;
//printf("Enter a String: ");
scanf("%s", str);
rev = reverse(str); //You have to write this function
printf("The reversed string is : %s\n", rev);
return 0;
}
char* reverse(char str[])
{
static int i= 0;
static char rev[MAX];
if (*str)
{
reverse(str+1);
rev[i++]= *str;
}
return rev;
}

```
```