Mmt 001

S

Please provide me the solution of the questions and send me to shubhananthakur@gmail.com

ASSIGNMENT BOOKLET
M.Sc.(Mathematics with Applications in Computer Science)
Programming and Data Structures
(Valid from 1st
January, 2014 to 30th
November, 2014)
School of Sciences
Indira Gandhi National Open University
Maidan Garhi,
New Delhi-110068
(For January, 2014 cycle)
MMT-001
It is compulsory to submit the assignment before filling
in the exam form.
2
Dear Student,
Please read the section on assignments in the Programme Guide for Elective courses that we sent you
after your enrolment. A weightage of 20%, as you are aware, has been earmarked for continuous
evaluation, which would consist of one tutor-marked assignment for this course. The assignment is in
this booklet.
Instructions for Formating Your Assignments
Before attempting the assignment please read the following instructions carefully.
1) On top of the first page of your answer sheet, please write the details exactly in the following format:
ROLL NO :……………………………………………
NAME :……………………………………………
ADDRESS :……………………………………………
……………………………………………
……………………………………………
COURSE CODE: …………………………….
COURSE TITLE : …………………………….
ASSIGNMENT NO.: ………………………….…
STUDY CENTRE: ………………………..….. DATE: ……………………….………………...
PLEASE FOLLOW THE ABOVE FORMAT STRICTLY TO FACILITATE EVALUATION AND
TO AVOID DELAY.
2) Use only foolscap size writing paper (but not of very thin variety) for writing your answers.
3) Leave 4 cm margin on the left, top and bottom of your answer sheet.
4) Your answers should be precise.
5) This assignment is to be submitted to the Study Centre as per the schedule made by the study centre.
Answer sheets received after the due date shall not be accepted.
We strongly suggest that you retain a copy of your answer sheets.
6) This assignment is valid only upto November, 2014. If you have failed in this assignment or fail to
submit it by November, 2014, then you need to get the assignment for the year 2015 and submit it as
per the instructions given in the programme guide.
7) You cannot fill the exam form for this course till you have submitted this assignment. So solve it
and submit it to your study centre at the earliest.
We wish you good luck.
3
Assignment
(To be done after studying the course material)
Course Code: MMT-001
Assignment Code: MMT-001/TMA/2014
Maximum Marks: 100
1. a) Debug the following C program:
#includ <stdio.h>;
int main()
{ int a, int b, int c;
printf(“a, b, c are integer variablesn”).
{ a =5; b=6; c=7;
printf(“The values of a, b and c are:” a, b, c);
printf(“na, b and c are consecutive integers.”);
return 0;
}
What will the output be after correcting the errors? [3]
b) Write C statements that show the use of the escape sequences n and t. [2]
c) The formula for converting the temperature from Fahrenheit to Celsius is
( )
Write a C program that implements this formula. Check your program for different
values of fahrenheit. [2]
d) Which of the following are valid C identifiers? [4]
(i) Sah_Rukh_Khan (ii) 01matrix
(iii) target_value (iv) etypedef
(v) L.C.M. (vi) A/c_balance
(vii) +ve_numbers (viii) _underscore
e) Evaluate the following expressions stepwise such that in each step only one operator
should be evaluated. [4]
(i)
(ii) ( ) ( )
(iii) ( ) ( )
(iv)
2. a) What error does the compiler show when the you run the following program? Explain
why this error occurs. How can you remove this error? [3]
#include <stdio.h>
int main()
{ int x=5, y,z;
y=---x;
printf("%d", y);
return 0;
}
4
b) Recall that the volume of a cylinder with radius and height is given by the
following formula:
Write a C program that calculates the volume of a cylinder using the above formula
and prints the result in right justified floating point format with width and having
digits after the decimal. [3]
c) If , , and are variables of type int having values , , and respectively,
what are the values of the following expressions? Justify your answers. [4]
(i) ( ) ( ) (ii)
(iii) (iv)
d) Write a C program that asks the user to enter a 4 digits number. If the number
entered by the user is matched with a specified number, then the program terminates
after displaying the message “Good Luck! You Succeed.” Otherwise it keeps asking
the user to enter a number upto wrong attempts. After wrong attempts the
program terminates with the message “Bad Luck? Try Again Next Time.” [3]
e) Look at the program 4.5 at Page No. 86 of Block 1 of your study material.
Do the following modifications:
(i) Replace the condition with in first if statement.
(ii) Replace the condition with in the second if statement.
(iii) Replace the condition by in the third if statement.
What will the output of the program be now? [2]
3. a) Explain the use of ternary if()- then- else operator with the help of an example. [3]
b) What does the following program calculates? Explain step by step the procedure. [4]
#include <stdio.h>
int main ()
{ int u, v, temp;
printf ("Please type in two nonnegative integers.n");
scanf ("%d%d", &u, &v);
while ( v != 0 )
{ temp = u % v;
u = v;
v = temp;
}
printf ("%dn", u);
return 0;
}
c) Using a simple example explain the difference between a pointer and an ordinary
variable. [3]
5
d) Write a C program to print the following: [6]
[Hint: Analyze the above figure before writing the program. First think how you can
print the slash’s and backslash’s. Then observe the pattern in each row.]
e) Define two integer arrays, each 10 elements long, called "array1" and "array2".
Using a loop, put some kind of data in each and add them term by term into another
10 element array named "arrays_sum".
Finally print all results in a table with an index number as given below. [4]
Sum of Two Integer Arrays
1. 2+10 = 12
2. 4+20 = 24
3. 6+30 = 36
….. etc.
4. a) Write a function named next_alphabet(…) that takes an English alphabet and
returns the next alphabet. If the alphabet is passed to the function then it should
return the alphabet . [3]
b) Write a C program to calculate the average of integers. The program should allocate
memory dynamically depending on the value of . [4]
[Hint: You should declare a pointer to int say and using either malloc( ) or
calloc( ) allocate bytes of memory of type int and assign them to . Rest is
easy.]
c) Write a C program that calls a function sum_of_squares(…) with variable length
argument list to return the sum of the squares of the arguments passed to it. [3]
d) Write a C program to perform following operations. [5]
(i) Open a file named Names.txt in write mode.
(ii) Read a list of names through keyboard using gets(…) function.
(iii) Write these names to Names.txt. Each name should be separated by a tab
character.
(iv) Close the file Names.txt and reopen it in read mode.
(v) Read the names from the file and display them on the monitor.
(vi) Close the file Names.txt.
5. a) Recall that the distance between a point ( , ) and a line is
given by the following formula:
Now define a point P and a line L using structs. Write a function that takes a line and
a point as its arguments and returns the distance between them using the above
formula. [4]
b) Discuss how would a array will be stored in Row Major order and
6
Column major order. [3]
c) How will you store the following sparse matrix in vector and linked list
representation so that only nonzero elements are stored? [3]
6. a) Define a node for a list of characters using doubly linked list. Write a function named
move_to_first( ) which takes a pointer to a node of the list and a character
and moves the character to the first location if it exists in the list otherwise displays
the message “Character not found”. Also write a function named display( )
that takes a pointer to node of the list and displays the contents of the list. [7]
b) Explain the procedure how recursion works using stacks. [3]
7. a) Evaluate the expression , , , , , , , , , , in RPN. [3]
b) Manually provide the inorder, preorder and postorder traversals of the following
binary search tree: [6]
c) Draw a binary tree for the expression )/(*)(* QPDCBA  [3]
d) Explain the procedure of deletion of a node in a binary search tree. [3]
45
25
12
2
15
26
30
52
50
35
53

Recomendados

C programming session 05 von
C programming session 05C programming session 05
C programming session 05Vivek Singh
397 views31 Folien
9608 Computer Science Cambridge International AS level Pre-Release May June p... von
9608 Computer Science Cambridge International AS level Pre-Release May June p...9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...Isham Rashik
2.5K views11 Folien
Visual Basic Source Codes for Class 11 HSc Paper 1 Practicals von
Visual Basic Source Codes for Class 11 HSc Paper 1 PracticalsVisual Basic Source Codes for Class 11 HSc Paper 1 Practicals
Visual Basic Source Codes for Class 11 HSc Paper 1 PracticalsAditi Bhushan
604 views4 Folien
E9 von
E9E9
E9lksoo
278 views4 Folien
complex c programming von
complex c programming complex c programming
complex c programming CenturyLink India
219 views2 Folien
End term bscs 2016 fall u et pp1 130516 von
End term bscs 2016 fall u et pp1 130516End term bscs 2016 fall u et pp1 130516
End term bscs 2016 fall u et pp1 130516ZUbaria Inayat
13 views1 Folie

Más contenido relacionado

Was ist angesagt?

11th information practices paper CBSE INDIA 2012 2013 von
11th information practices paper CBSE INDIA 2012 201311th information practices paper CBSE INDIA 2012 2013
11th information practices paper CBSE INDIA 2012 2013Harish Gyanani
243 views8 Folien
Oop december 2018 von
Oop december 2018Oop december 2018
Oop december 2018ktuonlinenotes
39 views2 Folien
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12 von
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12chinthala Vijaya Kumar
1K views15 Folien
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so... von
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...chinthala Vijaya Kumar
711 views14 Folien
Fy secondsemester2016 von
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
11 views33 Folien
Fy secondsemester2016 von
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
6 views33 Folien

Was ist angesagt?(20)

11th information practices paper CBSE INDIA 2012 2013 von Harish Gyanani
11th information practices paper CBSE INDIA 2012 201311th information practices paper CBSE INDIA 2012 2013
11th information practices paper CBSE INDIA 2012 2013
Harish Gyanani243 views
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12 von chinthala Vijaya Kumar
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so... von chinthala Vijaya Kumar
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...
Fy secondsemester2016 von Ankit Dubey
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
Ankit Dubey11 views
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN von Syahriha Ruslan
FP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAINFP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAIN
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN
Syahriha Ruslan15.2K views
Redo midterm von IIUM
Redo midtermRedo midterm
Redo midterm
IIUM640 views
Comp 328 final guide von krtioplal
Comp 328 final guideComp 328 final guide
Comp 328 final guide
krtioplal387 views
introductory concepts von Walepak Ubi
introductory conceptsintroductory concepts
introductory concepts
Walepak Ubi523 views
A01 von lksoo
A01A01
A01
lksoo368 views
C# programming (3rd semester) von Ketan Rajpal
C# programming (3rd semester)C# programming (3rd semester)
C# programming (3rd semester)
Ketan Rajpal218 views
C Programming Lab manual 18CPL17 von manjurkts
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
manjurkts18.4K views
Cpcs 203 -array-problems von MaherAalQasim
Cpcs 203 -array-problemsCpcs 203 -array-problems
Cpcs 203 -array-problems
MaherAalQasim1.8K views
Two dimensional arrays von Neeru Mittal
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
Neeru Mittal9.9K views

Destacado

first upload von
first uploadfirst upload
first uploadFarman Ichigo
133 views3 Folien
Aprendizajes por proyectos von
Aprendizajes por proyectosAprendizajes por proyectos
Aprendizajes por proyectosMagdalena Pérez Cortes
372 views15 Folien
Portfolio laag von
Portfolio laagPortfolio laag
Portfolio laagstudiograficolaag
224 views156 Folien
Aprendizajes por proyectos von
Aprendizajes por proyectosAprendizajes por proyectos
Aprendizajes por proyectosMagdalena Pérez Cortes
240 views15 Folien
el plagio academico von
el plagio academicoel plagio academico
el plagio academicoJuan Manuel Ospina Giraldo
358 views9 Folien
History 101 a visual example von
History 101 a visual exampleHistory 101 a visual example
History 101 a visual exampledarwinblade
441 views10 Folien

Destacado(13)

History 101 a visual example von darwinblade
History 101 a visual exampleHistory 101 a visual example
History 101 a visual example
darwinblade441 views
MakroPro100 pramoniniai garažo vartai be spyruoklių von OMETA UAB
MakroPro100 pramoniniai garažo vartai be spyruokliųMakroPro100 pramoniniai garažo vartai be spyruoklių
MakroPro100 pramoniniai garažo vartai be spyruoklių
OMETA UAB1.2K views
The Independent's top 10 Twitter blunders of 2013 von eviebool
The Independent's top 10 Twitter blunders of 2013The Independent's top 10 Twitter blunders of 2013
The Independent's top 10 Twitter blunders of 2013
eviebool1K views
Champagne Results on a Beer Budget: High-End PR for Less von sherreeg
Champagne Results on a Beer Budget: High-End PR for LessChampagne Results on a Beer Budget: High-End PR for Less
Champagne Results on a Beer Budget: High-End PR for Less
sherreeg1.1K views
Ponencia del Director de Marketing de "TWITTER FOR WLOGGERS" en WLOGGERS 2014 von WLOGGERS
Ponencia del Director de Marketing de "TWITTER FOR WLOGGERS" en WLOGGERS 2014Ponencia del Director de Marketing de "TWITTER FOR WLOGGERS" en WLOGGERS 2014
Ponencia del Director de Marketing de "TWITTER FOR WLOGGERS" en WLOGGERS 2014
WLOGGERS2.2K views
fi360 2013 Conference Session by Sharon Pivirotto von Sharon Pivirotto
fi360 2013 Conference Session by Sharon Pivirottofi360 2013 Conference Session by Sharon Pivirotto
fi360 2013 Conference Session by Sharon Pivirotto
Sharon Pivirotto846 views
IGNOU - Prospectus von Rakesh T
IGNOU - ProspectusIGNOU - Prospectus
IGNOU - Prospectus
Rakesh T17.6K views

Similar a Mmt 001

Name _______________________________ Class time __________.docx von
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
3 views19 Folien
[removed]DevelopingTechnical Software As.docx von
[removed]DevelopingTechnical Software As.docx[removed]DevelopingTechnical Software As.docx
[removed]DevelopingTechnical Software As.docxlanagore871
3 views6 Folien
Cp manual final von
Cp manual finalCp manual final
Cp manual finalitprasad1237
476 views71 Folien
Prerequisite Evaluation for Intermediate Programming T.docx von
Prerequisite Evaluation for Intermediate Programming  T.docxPrerequisite Evaluation for Intermediate Programming  T.docx
Prerequisite Evaluation for Intermediate Programming T.docxharrisonhoward80223
3 views7 Folien
Pcd201516 von
Pcd201516Pcd201516
Pcd201516sheikhmoidin
216 views2 Folien
Computer science sqp von
Computer science sqpComputer science sqp
Computer science sqpB Bhuvanesh
154 views15 Folien

Similar a Mmt 001(20)

Name _______________________________ Class time __________.docx von rosemarybdodson23141
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
[removed]DevelopingTechnical Software As.docx von lanagore871
[removed]DevelopingTechnical Software As.docx[removed]DevelopingTechnical Software As.docx
[removed]DevelopingTechnical Software As.docx
lanagore8713 views
Prerequisite Evaluation for Intermediate Programming T.docx von harrisonhoward80223
Prerequisite Evaluation for Intermediate Programming  T.docxPrerequisite Evaluation for Intermediate Programming  T.docx
Prerequisite Evaluation for Intermediate Programming T.docx
Computer science sqp von B Bhuvanesh
Computer science sqpComputer science sqp
Computer science sqp
B Bhuvanesh154 views
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21 von chinthala Vijaya Kumar
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
QUESTION ONE (14 MARKS) compulsorya. Discuss the features of o.docx von catheryncouper
QUESTION ONE (14 MARKS) compulsorya. Discuss the features of o.docxQUESTION ONE (14 MARKS) compulsorya. Discuss the features of o.docx
QUESTION ONE (14 MARKS) compulsorya. Discuss the features of o.docx
catheryncouper4 views
Spreadsheets 101 von whita1bd
Spreadsheets 101Spreadsheets 101
Spreadsheets 101
whita1bd689 views
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio... von Alpro
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Alpro16 views
EN3085 Assessed Coursework 1 1. Create a class Complex .docx von gidmanmary
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
gidmanmary3 views
EN3085 Assessed Coursework 1 1. Create a class Complex .docx von christinemaritza
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
Page 1 of 4 ANSWER QUESTION 1 AND ANY OTHER FOUR .docx von alfred4lewis58146
Page 1 of 4  ANSWER QUESTION 1 AND ANY OTHER FOUR .docxPage 1 of 4  ANSWER QUESTION 1 AND ANY OTHER FOUR .docx
Page 1 of 4 ANSWER QUESTION 1 AND ANY OTHER FOUR .docx
Sp 1418794917 von lakshmi r
Sp 1418794917Sp 1418794917
Sp 1418794917
lakshmi r152 views
Bsc math previous exam quetions von mshoaib15
Bsc math previous exam quetionsBsc math previous exam quetions
Bsc math previous exam quetions
mshoaib1513 views

Último

AUDIENCE - BANDURA.pptx von
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptxiammrhaywood
89 views44 Folien
Recap of our Class von
Recap of our ClassRecap of our Class
Recap of our ClassCorinne Weisgerber
81 views15 Folien
Women from Hackney’s History: Stoke Newington by Sue Doe von
Women from Hackney’s History: Stoke Newington by Sue DoeWomen from Hackney’s History: Stoke Newington by Sue Doe
Women from Hackney’s History: Stoke Newington by Sue DoeHistory of Stoke Newington
157 views21 Folien
Structure and Functions of Cell.pdf von
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdfNithya Murugan
701 views10 Folien
Computer Introduction-Lecture06 von
Computer Introduction-Lecture06Computer Introduction-Lecture06
Computer Introduction-Lecture06Dr. Mazin Mohamed alkathiri
102 views12 Folien
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptx von
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptxCollective Bargaining and Understanding a Teacher Contract(16793704.1).pptx
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptxCenter for Integrated Training & Education
94 views57 Folien

Último(20)

Structure and Functions of Cell.pdf von Nithya Murugan
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan701 views
Classification of crude drugs.pptx von GayatriPatra14
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra1492 views
The basics - information, data, technology and systems.pdf von JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1126 views
Dance KS5 Breakdown von WestHatch
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch86 views
Psychology KS5 von WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch103 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... von Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Psychology KS4 von WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch90 views
Sociology KS5 von WestHatch
Sociology KS5Sociology KS5
Sociology KS5
WestHatch76 views
REPRESENTATION - GAUNTLET.pptx von iammrhaywood
REPRESENTATION - GAUNTLET.pptxREPRESENTATION - GAUNTLET.pptx
REPRESENTATION - GAUNTLET.pptx
iammrhaywood107 views

Mmt 001

  • 1. ASSIGNMENT BOOKLET M.Sc.(Mathematics with Applications in Computer Science) Programming and Data Structures (Valid from 1st January, 2014 to 30th November, 2014) School of Sciences Indira Gandhi National Open University Maidan Garhi, New Delhi-110068 (For January, 2014 cycle) MMT-001 It is compulsory to submit the assignment before filling in the exam form.
  • 2. 2 Dear Student, Please read the section on assignments in the Programme Guide for Elective courses that we sent you after your enrolment. A weightage of 20%, as you are aware, has been earmarked for continuous evaluation, which would consist of one tutor-marked assignment for this course. The assignment is in this booklet. Instructions for Formating Your Assignments Before attempting the assignment please read the following instructions carefully. 1) On top of the first page of your answer sheet, please write the details exactly in the following format: ROLL NO :…………………………………………… NAME :…………………………………………… ADDRESS :…………………………………………… …………………………………………… …………………………………………… COURSE CODE: ……………………………. COURSE TITLE : ……………………………. ASSIGNMENT NO.: ………………………….… STUDY CENTRE: ………………………..….. DATE: ……………………….………………... PLEASE FOLLOW THE ABOVE FORMAT STRICTLY TO FACILITATE EVALUATION AND TO AVOID DELAY. 2) Use only foolscap size writing paper (but not of very thin variety) for writing your answers. 3) Leave 4 cm margin on the left, top and bottom of your answer sheet. 4) Your answers should be precise. 5) This assignment is to be submitted to the Study Centre as per the schedule made by the study centre. Answer sheets received after the due date shall not be accepted. We strongly suggest that you retain a copy of your answer sheets. 6) This assignment is valid only upto November, 2014. If you have failed in this assignment or fail to submit it by November, 2014, then you need to get the assignment for the year 2015 and submit it as per the instructions given in the programme guide. 7) You cannot fill the exam form for this course till you have submitted this assignment. So solve it and submit it to your study centre at the earliest. We wish you good luck.
  • 3. 3 Assignment (To be done after studying the course material) Course Code: MMT-001 Assignment Code: MMT-001/TMA/2014 Maximum Marks: 100 1. a) Debug the following C program: #includ <stdio.h>; int main() { int a, int b, int c; printf(“a, b, c are integer variablesn”). { a =5; b=6; c=7; printf(“The values of a, b and c are:” a, b, c); printf(“na, b and c are consecutive integers.”); return 0; } What will the output be after correcting the errors? [3] b) Write C statements that show the use of the escape sequences n and t. [2] c) The formula for converting the temperature from Fahrenheit to Celsius is ( ) Write a C program that implements this formula. Check your program for different values of fahrenheit. [2] d) Which of the following are valid C identifiers? [4] (i) Sah_Rukh_Khan (ii) 01matrix (iii) target_value (iv) etypedef (v) L.C.M. (vi) A/c_balance (vii) +ve_numbers (viii) _underscore e) Evaluate the following expressions stepwise such that in each step only one operator should be evaluated. [4] (i) (ii) ( ) ( ) (iii) ( ) ( ) (iv) 2. a) What error does the compiler show when the you run the following program? Explain why this error occurs. How can you remove this error? [3] #include <stdio.h> int main() { int x=5, y,z; y=---x; printf("%d", y); return 0; }
  • 4. 4 b) Recall that the volume of a cylinder with radius and height is given by the following formula: Write a C program that calculates the volume of a cylinder using the above formula and prints the result in right justified floating point format with width and having digits after the decimal. [3] c) If , , and are variables of type int having values , , and respectively, what are the values of the following expressions? Justify your answers. [4] (i) ( ) ( ) (ii) (iii) (iv) d) Write a C program that asks the user to enter a 4 digits number. If the number entered by the user is matched with a specified number, then the program terminates after displaying the message “Good Luck! You Succeed.” Otherwise it keeps asking the user to enter a number upto wrong attempts. After wrong attempts the program terminates with the message “Bad Luck? Try Again Next Time.” [3] e) Look at the program 4.5 at Page No. 86 of Block 1 of your study material. Do the following modifications: (i) Replace the condition with in first if statement. (ii) Replace the condition with in the second if statement. (iii) Replace the condition by in the third if statement. What will the output of the program be now? [2] 3. a) Explain the use of ternary if()- then- else operator with the help of an example. [3] b) What does the following program calculates? Explain step by step the procedure. [4] #include <stdio.h> int main () { int u, v, temp; printf ("Please type in two nonnegative integers.n"); scanf ("%d%d", &u, &v); while ( v != 0 ) { temp = u % v; u = v; v = temp; } printf ("%dn", u); return 0; } c) Using a simple example explain the difference between a pointer and an ordinary variable. [3]
  • 5. 5 d) Write a C program to print the following: [6] [Hint: Analyze the above figure before writing the program. First think how you can print the slash’s and backslash’s. Then observe the pattern in each row.] e) Define two integer arrays, each 10 elements long, called "array1" and "array2". Using a loop, put some kind of data in each and add them term by term into another 10 element array named "arrays_sum". Finally print all results in a table with an index number as given below. [4] Sum of Two Integer Arrays 1. 2+10 = 12 2. 4+20 = 24 3. 6+30 = 36 ….. etc. 4. a) Write a function named next_alphabet(…) that takes an English alphabet and returns the next alphabet. If the alphabet is passed to the function then it should return the alphabet . [3] b) Write a C program to calculate the average of integers. The program should allocate memory dynamically depending on the value of . [4] [Hint: You should declare a pointer to int say and using either malloc( ) or calloc( ) allocate bytes of memory of type int and assign them to . Rest is easy.] c) Write a C program that calls a function sum_of_squares(…) with variable length argument list to return the sum of the squares of the arguments passed to it. [3] d) Write a C program to perform following operations. [5] (i) Open a file named Names.txt in write mode. (ii) Read a list of names through keyboard using gets(…) function. (iii) Write these names to Names.txt. Each name should be separated by a tab character. (iv) Close the file Names.txt and reopen it in read mode. (v) Read the names from the file and display them on the monitor. (vi) Close the file Names.txt. 5. a) Recall that the distance between a point ( , ) and a line is given by the following formula: Now define a point P and a line L using structs. Write a function that takes a line and a point as its arguments and returns the distance between them using the above formula. [4] b) Discuss how would a array will be stored in Row Major order and
  • 6. 6 Column major order. [3] c) How will you store the following sparse matrix in vector and linked list representation so that only nonzero elements are stored? [3] 6. a) Define a node for a list of characters using doubly linked list. Write a function named move_to_first( ) which takes a pointer to a node of the list and a character and moves the character to the first location if it exists in the list otherwise displays the message “Character not found”. Also write a function named display( ) that takes a pointer to node of the list and displays the contents of the list. [7] b) Explain the procedure how recursion works using stacks. [3] 7. a) Evaluate the expression , , , , , , , , , , in RPN. [3] b) Manually provide the inorder, preorder and postorder traversals of the following binary search tree: [6] c) Draw a binary tree for the expression )/(*)(* QPDCBA  [3] d) Explain the procedure of deletion of a node in a binary search tree. [3] 45 25 12 2 15 26 30 52 50 35 53