SlideShare a Scribd company logo
1 of 11
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
Course Code : MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/13
Maximum Marks : 100
Weightage : 25%
Last Dates for Submission : 15th October, 2013 (For July 2013 Session) 15th April, 2014 (For
January 2014 Session)
There are six questions in this assignment, which carry 80 marks. Rest 20 marks are for viva-voce.
Answer all the questions. You may use illustrations and diagrams to enhance the explanations.
Please go through the guidelines regarding assignments given in the Programme Guide for the
format of presentation. Insert comments in the coding for better understanding.
Question 1:
Write a C program to find out perfect numbers from 1 and 50 .
Solution :
#include<stdio.h>
#include<conio.h> voidmain()
{
voidperfect(); clrscr(); perfect(); getch();
}
void perfect()
{
int n,i,s,lim; lim=1; while(lim<=50)
{ i=1;s=0;
while(i<lim)
{
if(lim%i==0)
{
s=s+i;
} i++;
}
if(s==lim)
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
printf("perfect no =%dn",lim); lim++;
}
}
 Question 2: Write an algorithm, draw a corresponding flowchart and write an interactive
program to convert a binary number to its octal equivalent.
Solution :
Alogrithm:
Binary to octal conversion method:
Step1: Arrange the binary number in the group 3 from
right side.
Step 2: Replace the each group with following
values:
Binary number Octal values
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
Binary to octal chart
Binary to octal conversion examples:
For example we want to convert binary number
1011010101001101 to octal.
Step 1: 001 011 010 101 001 101
Step 2: 1 3 2 5 1 5
So (1011010101001101)2 = (132515)8
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
c program to convert binary to octal
#include<stdio.h>
int main(){
long int binaryNumber,octalNumber=0,j=1,remainder;
printf("Enter any number any binary number: ");
scanf("%ld",&binaryNumber);
while(binaryNumber!=0){
remainder=binaryNumber%10;
octalNumber=octalNumber+remainder*j;
j=j*2;
binaryNumber=binaryNumber/10;
}
printf("Equivalent octal value:
%lo",octalNumber);
return 0;
}
Sample output:
Enter any number any binary number: 1101
Equivalent hexadecimal value: 15
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
Question 3 : Write the function strreplace(s, chr, repl_chr)
which will replace each occurrences of character chr with the
character repl_chr in the string s. The function returns the
number of replacements. Place the source code of this function in
a file named strreplace.c
Solution :
char *replace_str(const char *str, const char *old, const char
*new)
{
char *ret, *r;
const char *p, *q;
size_t oldlen = strlen(old);
size_t count, retlen, newlen = strlen(new);
if (oldlen != newlen) {
for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q +
oldlen)
count++;
/* this is undefined if p - str > PTRDIFF_MAX */
retlen = p - str + strlen(p) + count * (newlen - oldlen);
} else
retlen = strlen(str);
if ((ret = malloc(retlen + 1)) == NULL)
return NULL;
for (r = ret, p = str; (q = strstr(p, old)) != NULL; p = q +
oldlen) {
/* this is undefined if q - p > PTRDIFF_MAX */
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
ptrdiff_t l = q - p;
memcpy(r, p, l);
r += l;
memcpy(r, new, newlen);
r += newlen;
}
strcpy(r, p);
return ret;
}
Question 4: Writer an interactive C program to check whether the given string is a palindrome or
not, using pointers.
Solution :
#include<stdio.h>
#include<conio.h>
int main()
{
char str[30];
char *p,*t;
printf("Enter any string : ");
gets(str);
for(p=str ; *p!=NULL ; p++);
for(t=str, p-- ; p>=t; )
{
if(*p==*t)
{
p--;
t++;
}
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
else
break;
}
if(t>p)
printf("nString is palindrome");
else
printf("nString is Not palindrome");
getch();
return 0;
}
Question 5: Write an interactive program called “WEIGHT CONVERTER” that accepts the
weight in milligrams / decigrams / centigrams / kilograms /ounces / pounds / tons and displays its
equivalent in grams .
Solution :
#include <stdio.h>
void print_converted(int pounds)
/* Convert U.S. Weight to Imperial and International
Units. Print the results */
{ int stones = pounds / 14;
int uklbs = pounds % 14;
float kilos_per_pound = 0.45359;
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
float kilos = pounds * kilos_per_pound;
printf(" %3d %2d %2d %6.2f", pounds, stones, uklbs, kilos);
}
Main (int argc,char *argv[])
{ int pounds;
if(argc != 2)
{ printf ("Usage: convert weight_in_pounds");
exit(1);
}
Sscanf (argv[1], "%d", &pounds); /* Convert String to int */
Printf (" US lbs UK st. lbs INT Kg");
print_converted (pounds);
}
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
Question 6. Write an interactive program to generate pay slips for the staff of size 12 employees
(2 members are clerks, one computer operator, 6 salesmen, 3 helpers) , working in a small chemist
retail shop.
Assumptions can be made wherever necessary. The payslip should display the employee no.,
employee name, no. of days worked during the month, date of generation of the payslip, month
for which the salary is being paid, all the details of the payment, deductions, gross-pay and net-
pay.
Solution :
#include<stdio.h>
#include<conio.h> void main()
{
int n,i,k;
struct employee
{
char name[50],des[30],mon[10],level; int empid,accno;
float hra,da,cca,ca,gpf,grossal,totdeduc,netsal,basic;
}emp[10];
clrscr();
printf("ENTER THE NUMBER OF EMPLOYEE: ");
scanf("%d",&n); for(i=1;i<=n;i++)
{
printf("n ENTER NAME OF THE EMPLOYEE:");
scanf("%s",emp[i].name);
printf("n ENTER DESIGANTION OF THE EMPLOYEE:");
scanf("%s",emp[i].des); printf("n ENTER MONTH:"); scanf("%s",emp[i].mon);
printf("n ENTER EMPLOYEE ID:");
scanf("%d",&emp[i].empid); printf("n ENTER ACCNO:"); scanf("%d",&emp[i].accno);
printf("nENTER BASIC PAY: ");
scanf("%f",&emp[i].basic);
printf("ENTER CITY LEVEL: ");
scanf("%s",&emp[i].level);
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
}
for(i=1;i<=n;i++)
{
emp[i].hra=emp[i].basic*0.30; if(emp[i].basic<=6500)
emp[i].ca=100; else
{
if(emp[i].basic>6500&&emp[i].basic<=8000)
emp[i].ca=400; else emp[i].ca=800;
}
emp[i].da=emp[i].basic/2; if(emp[i].level=='a'||emp[i].level=='A')
emp[i].cca=400; else
{
if(emp[i].level=='b'||emp[i].level=='B') emp[i].cca=100;
else
emp[i].cca=50;
}
emp[i].gpf=emp[i].basic * 0.075; emp[i].grossal=emp[i].basic+emp[i].hra+emp[i].da+emp[ i].cca;
emp[i].totdeduc=emp[i].gpf;
emp[i].netsal=emp[i].grossal-emp[i].totdeduc;
}
for(i=1;i<=n;i++)
{
do
{ clrscr();
printf("ntt V R SIDDHARTHA ENGINEERNG COLLEGE");
printf("nttt KANURU::VIJAYAWADA-7n"); printf("ntttt PAY SLIP");
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
printf("nttt************************"); printf("nttt Salary Slip for %s ",emp[i].mon);
printf("nttt***********************"); printf("nn tNAME: %s tttEMPID: %d
",emp[i].name,emp[i].empid);
printf("nn tDESIGNATION:%s
ttACCNO:%d",emp[i].des,emp[i].accno);
printf("n-----------------------------------------
----n");
printf("<----------EARNINGS----------> <------- DEDUCTIONS------------>n");
printf("n BASIC=%f
ttttP.F.=%.2f",emp[i].basic,emp[i].gpf);
printf("nn D.A=%.2f ttttINCOME TAX=",emp[i].da);
printf("nn H.R.A=%.2f ttttP.F. LOAN=",emp[i].hra);
printf("nn C.C.A=%.2f
ttttL.I.C=",emp[i].cca);
printf("nn---------------------------------------
----------");
printf("nn GROSS SALARY=%.2f ttTOTAL DEDUCTIONS=%.2f " ,emp[i].grossal,emp[i].totdeduc);
printf("nn---------------------------------------
------------");
printf("nnttt NET SALARY=%.2f",emp[i].netsal); printf("nn---------------------------------------
------------");
printf("nnnttttttEMPLOYEE SIGNATURE"); printf("nnnPRESS 1 TO NEXT ......");
scanf("%d",&k);
}while(k==2);
}
getch();
}
For More Ignou Solved Assignments Please Visit -
www.ignousolvedassignments.com
For more IGNOU solved assignments please visit - www.ignousolvedassignments.com
Connect on Facebook :
https://www.facebook.com/pages/IgnouSolvedAssignmentscom/346544145433550
Subscribe and Get Solved Assignments Direct to your Inbox :
http://feedburner.google.com/fb/a/mailverify?uri=ignousolvedassignments_
com

More Related Content

Viewers also liked

(Www.entrance exam.net)-ignou mca solved assignment 2011
(Www.entrance exam.net)-ignou mca  solved assignment 2011(Www.entrance exam.net)-ignou mca  solved assignment 2011
(Www.entrance exam.net)-ignou mca solved assignment 2011swatith
 
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENT
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENTMS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENT
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENTDharmendra Sikarwar
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Dr. Loganathan R
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 

Viewers also liked (6)

(Www.entrance exam.net)-ignou mca solved assignment 2011
(Www.entrance exam.net)-ignou mca  solved assignment 2011(Www.entrance exam.net)-ignou mca  solved assignment 2011
(Www.entrance exam.net)-ignou mca solved assignment 2011
 
Mcs 012 soved assignment 2015-16
Mcs 012 soved assignment 2015-16Mcs 012 soved assignment 2015-16
Mcs 012 soved assignment 2015-16
 
Mcs 014 solved assignment 2015-16
Mcs 014 solved assignment 2015-16Mcs 014 solved assignment 2015-16
Mcs 014 solved assignment 2015-16
 
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENT
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENTMS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENT
MS-05 JAN JUNE 2016 SOLVED IGNOU ASSIGNMENT
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 

More from Indira Gnadhi National Open University (IGNOU) (14)

Mcs 16 solved assignment 2015-16
Mcs 16 solved assignment 2015-16Mcs 16 solved assignment 2015-16
Mcs 16 solved assignment 2015-16
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
BCSL 057 solved assignments
BCSL 057 solved assignmentsBCSL 057 solved assignments
BCSL 057 solved assignments
 
BCSL 056 solved assignment
BCSL 056 solved assignmentBCSL 056 solved assignment
BCSL 056 solved assignment
 
Bcs 055 solved 2014-15
Bcs 055 solved 2014-15Bcs 055 solved 2014-15
Bcs 055 solved 2014-15
 
Bcs 054 solved assignment
Bcs 054 solved assignmentBcs 054 solved assignment
Bcs 054 solved assignment
 
Bcs 053 solved assignment 2014-15
Bcs 053 solved assignment 2014-15Bcs 053 solved assignment 2014-15
Bcs 053 solved assignment 2014-15
 
Bcs 052 solved assignment
Bcs 052 solved assignmentBcs 052 solved assignment
Bcs 052 solved assignment
 
Mcs 021 solve assignment
Mcs 021 solve assignmentMcs 021 solve assignment
Mcs 021 solve assignment
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Bcsl 033 solve assignment
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
2012 bcsl-021 solve assihnment
2012 bcsl-021 solve assihnment2012 bcsl-021 solve assihnment
2012 bcsl-021 solve assihnment
 
Bcsl 022 solved-assignment_2012-13
Bcsl 022 solved-assignment_2012-13Bcsl 022 solved-assignment_2012-13
Bcsl 022 solved-assignment_2012-13
 
Eco 02 question paper
Eco 02 question paperEco 02 question paper
Eco 02 question paper
 

Recently uploaded

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 

Recently uploaded (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

MCS 011 SOLVED ASSIGNMENTS

  • 1. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com Course Code : MCS-011 Course Title : Problem Solving and Programming Assignment Number : MCA(1)/011/Assign/13 Maximum Marks : 100 Weightage : 25% Last Dates for Submission : 15th October, 2013 (For July 2013 Session) 15th April, 2014 (For January 2014 Session) There are six questions in this assignment, which carry 80 marks. Rest 20 marks are for viva-voce. Answer all the questions. You may use illustrations and diagrams to enhance the explanations. Please go through the guidelines regarding assignments given in the Programme Guide for the format of presentation. Insert comments in the coding for better understanding. Question 1: Write a C program to find out perfect numbers from 1 and 50 . Solution : #include<stdio.h> #include<conio.h> voidmain() { voidperfect(); clrscr(); perfect(); getch(); } void perfect() { int n,i,s,lim; lim=1; while(lim<=50) { i=1;s=0; while(i<lim) { if(lim%i==0) { s=s+i; } i++; } if(s==lim)
  • 2. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com printf("perfect no =%dn",lim); lim++; } }  Question 2: Write an algorithm, draw a corresponding flowchart and write an interactive program to convert a binary number to its octal equivalent. Solution : Alogrithm: Binary to octal conversion method: Step1: Arrange the binary number in the group 3 from right side. Step 2: Replace the each group with following values: Binary number Octal values 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7 Binary to octal chart Binary to octal conversion examples: For example we want to convert binary number 1011010101001101 to octal. Step 1: 001 011 010 101 001 101 Step 2: 1 3 2 5 1 5 So (1011010101001101)2 = (132515)8
  • 3. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com c program to convert binary to octal #include<stdio.h> int main(){ long int binaryNumber,octalNumber=0,j=1,remainder; printf("Enter any number any binary number: "); scanf("%ld",&binaryNumber); while(binaryNumber!=0){ remainder=binaryNumber%10; octalNumber=octalNumber+remainder*j; j=j*2; binaryNumber=binaryNumber/10; } printf("Equivalent octal value: %lo",octalNumber); return 0; } Sample output: Enter any number any binary number: 1101 Equivalent hexadecimal value: 15
  • 4. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com Question 3 : Write the function strreplace(s, chr, repl_chr) which will replace each occurrences of character chr with the character repl_chr in the string s. The function returns the number of replacements. Place the source code of this function in a file named strreplace.c Solution : char *replace_str(const char *str, const char *old, const char *new) { char *ret, *r; const char *p, *q; size_t oldlen = strlen(old); size_t count, retlen, newlen = strlen(new); if (oldlen != newlen) { for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen) count++; /* this is undefined if p - str > PTRDIFF_MAX */ retlen = p - str + strlen(p) + count * (newlen - oldlen); } else retlen = strlen(str); if ((ret = malloc(retlen + 1)) == NULL) return NULL; for (r = ret, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen) { /* this is undefined if q - p > PTRDIFF_MAX */
  • 5. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com ptrdiff_t l = q - p; memcpy(r, p, l); r += l; memcpy(r, new, newlen); r += newlen; } strcpy(r, p); return ret; } Question 4: Writer an interactive C program to check whether the given string is a palindrome or not, using pointers. Solution : #include<stdio.h> #include<conio.h> int main() { char str[30]; char *p,*t; printf("Enter any string : "); gets(str); for(p=str ; *p!=NULL ; p++); for(t=str, p-- ; p>=t; ) { if(*p==*t) { p--; t++; }
  • 6. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com else break; } if(t>p) printf("nString is palindrome"); else printf("nString is Not palindrome"); getch(); return 0; } Question 5: Write an interactive program called “WEIGHT CONVERTER” that accepts the weight in milligrams / decigrams / centigrams / kilograms /ounces / pounds / tons and displays its equivalent in grams . Solution : #include <stdio.h> void print_converted(int pounds) /* Convert U.S. Weight to Imperial and International Units. Print the results */ { int stones = pounds / 14; int uklbs = pounds % 14; float kilos_per_pound = 0.45359;
  • 7. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com float kilos = pounds * kilos_per_pound; printf(" %3d %2d %2d %6.2f", pounds, stones, uklbs, kilos); } Main (int argc,char *argv[]) { int pounds; if(argc != 2) { printf ("Usage: convert weight_in_pounds"); exit(1); } Sscanf (argv[1], "%d", &pounds); /* Convert String to int */ Printf (" US lbs UK st. lbs INT Kg"); print_converted (pounds); }
  • 8. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com Question 6. Write an interactive program to generate pay slips for the staff of size 12 employees (2 members are clerks, one computer operator, 6 salesmen, 3 helpers) , working in a small chemist retail shop. Assumptions can be made wherever necessary. The payslip should display the employee no., employee name, no. of days worked during the month, date of generation of the payslip, month for which the salary is being paid, all the details of the payment, deductions, gross-pay and net- pay. Solution : #include<stdio.h> #include<conio.h> void main() { int n,i,k; struct employee { char name[50],des[30],mon[10],level; int empid,accno; float hra,da,cca,ca,gpf,grossal,totdeduc,netsal,basic; }emp[10]; clrscr(); printf("ENTER THE NUMBER OF EMPLOYEE: "); scanf("%d",&n); for(i=1;i<=n;i++) { printf("n ENTER NAME OF THE EMPLOYEE:"); scanf("%s",emp[i].name); printf("n ENTER DESIGANTION OF THE EMPLOYEE:"); scanf("%s",emp[i].des); printf("n ENTER MONTH:"); scanf("%s",emp[i].mon); printf("n ENTER EMPLOYEE ID:"); scanf("%d",&emp[i].empid); printf("n ENTER ACCNO:"); scanf("%d",&emp[i].accno); printf("nENTER BASIC PAY: "); scanf("%f",&emp[i].basic); printf("ENTER CITY LEVEL: "); scanf("%s",&emp[i].level);
  • 9. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com } for(i=1;i<=n;i++) { emp[i].hra=emp[i].basic*0.30; if(emp[i].basic<=6500) emp[i].ca=100; else { if(emp[i].basic>6500&&emp[i].basic<=8000) emp[i].ca=400; else emp[i].ca=800; } emp[i].da=emp[i].basic/2; if(emp[i].level=='a'||emp[i].level=='A') emp[i].cca=400; else { if(emp[i].level=='b'||emp[i].level=='B') emp[i].cca=100; else emp[i].cca=50; } emp[i].gpf=emp[i].basic * 0.075; emp[i].grossal=emp[i].basic+emp[i].hra+emp[i].da+emp[ i].cca; emp[i].totdeduc=emp[i].gpf; emp[i].netsal=emp[i].grossal-emp[i].totdeduc; } for(i=1;i<=n;i++) { do { clrscr(); printf("ntt V R SIDDHARTHA ENGINEERNG COLLEGE"); printf("nttt KANURU::VIJAYAWADA-7n"); printf("ntttt PAY SLIP");
  • 10. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com printf("nttt************************"); printf("nttt Salary Slip for %s ",emp[i].mon); printf("nttt***********************"); printf("nn tNAME: %s tttEMPID: %d ",emp[i].name,emp[i].empid); printf("nn tDESIGNATION:%s ttACCNO:%d",emp[i].des,emp[i].accno); printf("n----------------------------------------- ----n"); printf("<----------EARNINGS----------> <------- DEDUCTIONS------------>n"); printf("n BASIC=%f ttttP.F.=%.2f",emp[i].basic,emp[i].gpf); printf("nn D.A=%.2f ttttINCOME TAX=",emp[i].da); printf("nn H.R.A=%.2f ttttP.F. LOAN=",emp[i].hra); printf("nn C.C.A=%.2f ttttL.I.C=",emp[i].cca); printf("nn--------------------------------------- ----------"); printf("nn GROSS SALARY=%.2f ttTOTAL DEDUCTIONS=%.2f " ,emp[i].grossal,emp[i].totdeduc); printf("nn--------------------------------------- ------------"); printf("nnttt NET SALARY=%.2f",emp[i].netsal); printf("nn--------------------------------------- ------------"); printf("nnnttttttEMPLOYEE SIGNATURE"); printf("nnnPRESS 1 TO NEXT ......"); scanf("%d",&k); }while(k==2); } getch(); } For More Ignou Solved Assignments Please Visit - www.ignousolvedassignments.com
  • 11. For more IGNOU solved assignments please visit - www.ignousolvedassignments.com Connect on Facebook : https://www.facebook.com/pages/IgnouSolvedAssignmentscom/346544145433550 Subscribe and Get Solved Assignments Direct to your Inbox : http://feedburner.google.com/fb/a/mailverify?uri=ignousolvedassignments_ com