NPTEL PROGRAMMING ASSIGNMENTS
Problem Solving Through Programming in C
Week-10 Problem-01
Due Date of Submission 2022-04-07, 23:59 ISTWrite a C program to sort a given 1D array using pointer in ascending order.
#include <stdio.h>int main(){ int a[100],i, n; scanf("%d",&n); for (i=0; i<n; i++) { scanf("%d",a+i); }
Write a C program to sort a given 1D array using pointer in ascending order.
#include <stdio.h>
int main()
{
int a[100],i, n;
scanf("%d",&n);
for (i=0; i<n; i++)
{
scanf("%d",a+i);
}
Week-10 Problem-02
Due Date of Submission 2022-04-07, 23:59 IST
Write a C program to sort a 1D array using pointer by applying Bubble sort technique.
#include<stdio.h>
void sort(int *a, int n);
int main()
{
int a[20];
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a, n);
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
Week-10 Program-03
Due Date of Submission 2022-04-07, 23:59 IST
Write a C code to check if a 3 x 3 matrix is invertible. A matrix is not invertible if its determinant is 0.
#include<stdio.h>
int main()
{
int a[3][3], i, j;
long determinant;
for(i = 0 ; i < 3; i++)
for(j = 0; j < 3; j++)
scanf("%d", &a[i][j]);
Week-10 Program-04
Due Date of Submission 2022-04-07, 23:59 IST
Write a C code to find the root ofthe equation using Newton Raphson method.f(x) =x3 - 2x - 3
The maximum number of steps are taken as input.
#include<stdio.h>
float f(float x);
float df (float x);
int main()
{
int itr, maxmitr;
float x0=1.0, x1;
scanf("%d", &maxmitr);