# Introduction To Programming In C NPTEL Assignment 4 Answers

Introduction To Programming In C NPTEL Assignment 4 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.

## What is Introduction To Programming In C?

This is a course in programming in C. No prior programming experience is assumed; however, mathematical maturity at the level of a second-year science or engineering undergraduate is assumed. We emphasize solving problems using the language and introduce standard programming techniques like alternation, iteration, and recursion. We will briefly glimpse the basics of software engineering practices like modularization, commenting, and naming conventions which help in collaborating and programming in teams.

## CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 6 assignments out of the total 8 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 THE 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.

## Introduction To Programming In C NPTEL Assignment 4 Answers 2022:-

Q1. Given two arrays of integers output the largest number in the first array not present in the second one.

Code:-

``````#include<stdio.h>
int main()
{
int n,m,i,j,c=0,temp,f=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&m);
int b[m];
for(i=0;i<m;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for(i=n-1;i>=0;i--)
{
for(j=0;j<m;j++)
{
if(a[i]==b[j])
{
c++;
}
}
if(c==0)
{
printf("%d",a[i]);
f=1;
break;
}
else
{
c=0;
}
}
if(f==0)
{
printf("0");
}
return 0;
}``````

Q2. Write a program that replaces the occurence of a given character (say c) in a primary string (say PS) with another string (say s).

Code:-

``````#include<stdio.h>
int main()
{
char PS, S, c;
char *ptr=PS, *ptr2=S;
int i=0;
scanf("%s",ptr);
getchar();
scanf("%c",&c);
scanf("%s",ptr2);

for( i=0;ptr[i]!='\0';i++)
{
if(ptr[i]==c)
{
printf("%s",ptr2);

}
else
printf("%c",ptr[i]);

}
return 0;
}``````

Q3. Given a threshold floating point number and an array of floating point numbers strictly between 0 and 1.    Modify the array with the following rules: If the number is greater than threshold value, change it to 1 and if less     than or equal to threshold value, change to 0.

Code:-

``````#include<stdio.h>
int main()
{
float farray;
float tvalue;
int sum;
int n;
scanf("%f", &tvalue);
scanf("%d", &n);

for (int i = 0; i < n; i++)
{
scanf("%f", &farray[i]);
}

for (int i = 0; i < n; i++)
{
if(farray[i] > tvalue)
{
sum = sum + 1;
}
}
printf("%d", sum);
return 0;
}``````

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.