# Introduction To Programming In C NPTEL Assignment 3 Answers

Introduction To Programming In C NPTEL Assignment 3 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 3 Answers 2022:-

Q1. Write a C function to find the kth occurrence of an odd integer in a sequence of non-negative integers, and then call your function from main.

Code:-

``````#include<stdio.h>
int find_odd (int k)
{
int num, i=1, seq=0;
scanf("%d",&num);
while (num!=-1)
{
if ((num%2==1)&&(i<=k))
{
seq=num;
i++;
}
scanf("%d",&num);
}
if(seq==0 || i<=k)
seq=-1;
return seq;
}

int main()
{
int k, seq;
scanf("%d",&k);
seq=find_odd(k);
printf("%d", seq);
return 0;
}``````

Q2. In this question, you have to output the “moving average” of asequence of non-negative numbers. The moving average is the sequenceof averages of the last 2 entries. For the first number, no averageis output.

Code:-

``````#include<stdio.h>
int main()
{
float a,b;
scanf("%f%f", &a, &b);
do
{

printf("%.1f ", (a+b)/2);
a=b;
scanf("%f", &b);
}while(b!=-1);
return 0;
}``````

Q3. Write a C program to list all the factorial numbers less than or equalto an input number n.

Code:-

``````#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, i=1, j, fact;
scanf("%d", &n);
while (1)
{
fact = 1;
for (j=1; j<=i; j++)
{
fact = fact * j;
}
if(fact <= n)
{
printf("%d ", fact);
i++;
}
else
{
exit(1);
}
}
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.