# Introduction To Programming In C NPTEL Assignment 7 Answers

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

Q1. Create a database of students using structures, wherein each entry of the database will have the following fields:

1. a name, which is a string with at most 128 characters
2. their marks in physics which is an int between 0 and 100
3. their marks in chemistry which is an int number between 0 and 100
4. their marks in mathematics which is an int number between 0 and 100

Code:-

``````#include<stdio.h>
struct student{
char name;
int p,c,m;
}s,t;

int main()
{
int i,n,j;
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%s%d%d%d", s[i].name, &s[i].p, &s[i].c, &s[i].m);
}

for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if((s[i].p>s[j].p) || ((s[i].p==s[j].p) && (s[i].c>s[j].c)))
{
t = s[i];
s[i] = s[j];
s[j] = t;
}
}
}
for(i=0; i<n; i++)
{
printf("%s-%d-%d-%d\n", s[i].name, s[i].p, s[i].c, s[i].m);
}
return 0;

}  ``````

Q2. You are given a sequence of integers terminated with a -1. The -1 isnot part of the input sequence.

Next, you are given a positive number N.
You have to create a linked list with the input sequence of integersas entries. You can use the following structure.
struct node{  int data; struct node *next; };

Code:-

``````#include<stdio.h>
#include<stdlib.h>

struct node {
int data;
struct node *next;
}*start = NULL;

int main() {
int n, N, count = 0;
struct node *newnode, *temp;
scanf("%d", &n);
while (n != -1)
{
newnode = (struct node *)malloc(sizeof(struct node));
newnode -> data = n;
newnode -> next = NULL;

if (start == NULL)
start = newnode;
else
{
temp = start;
while (temp -> next != NULL)
{
temp = temp -> next;
}
temp -> next = newnode;
}
count++;
scanf("%d", &n);
}
scanf("%d", &N);
if (N > count)
{
printf("-1");
return 0;
}
while (count > N)
{
start = start -> next;
count--;
}
temp = start;
while (temp != NULL)
{
printf("%d ", temp -> data);
temp = temp -> next;
}
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.

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

### 4 thoughts on “Introduction To Programming In C NPTEL Assignment 7 Answers”

1. Please update week 7 Assignment Solution

2. Online exam question 2
You are given a “secret” string, and you are given a “guess”
string. Both strings have exactly 5 characters.

Assume that each letter occurs at most one time in the secret string and the
guess string.

Some of the letters in the guess string occur in the same position as
the secret string. Call the number of such letters as I.

Some other letters in the guess string occur in the secret string, but
in some other position. Call the number of such letters as J.

You have to output
I#J
#include
int main()
{
int i=0,j=0,a,b;
char s,g;
scanf(“%s%s”,s,g);
for(a=0;a<5;a++)
{
if(s[a]==g[a])
{
i+=1;
}
else
{
for(b=0;b<5;b++)
{
if(s[a]==g[b])
{
j+=1;
}
}
}
}
printf("%d#%d",i,j);
return 0;
}

3. Online programming test Question 3
Detect whether a given positive integer N can be written as a
product of powers of 2, 3 and 5. That is, check whether N is exactly
equal to

2^i x 3^j x 5^k

where i>=0, j>=0, and k>=0 are non-negative integers.

If yes, then print
i#j#k
Otherwise, print
no

You can assume that N<9999.

#include
int main()
{
int N,i=0,j=0,k=0;
scanf(“%d”,&N);
while(N>1)
{
if(N%2==0)
{
i++;
N=N/2;
}
else if(N%3==0)
{
j++;
N=N/3;
}
else if(N%5==0)
{
k++;
N=N/5;
}
else
{
N=-1;
break;
}
}
if(N==-1)
printf(“no”);
else
printf(“%d#%d#%d”,i,j,k);
return 0;
}