SlideShare uma empresa Scribd logo
1 de 20
IGNOU SOLVED ASSIGNMENT
2018
MCS-011 PROBLEM SOLVING
AND PROGRAMMING
• QUESTION1. convert octal to decimal
• ANSWER:
• The Octal Number System is a type of computer and digital
numbering system which uses the Base-8 system.
• Octal numbers therefore have a range of just “8” digits, (0,
1, 2, 3, 4, 5, 6, 7) making them a Base-8 numbering system.
• Then the main characteristics of an Octal Numbering
System is that there are only 8 distinct counting digits from
0 to 7 with
• each digit having a weight or value of just 8 starting from
the least significant bit (LSB).
•
•
• program:
• #include<stdio.h>
• #include<math.h>
•
• int oct;
• int decimal=0;
• int a;
• int i=0;
•
• void main()
• { clrscr();
• printf("ENTER A OCTAL NUMBER:n");
• scanf("%d",&oct);
• if(oct==8 ||oct==9)
• {
printf("**** IT IS NOT AN OCTAL NUMBER KINDLY USE(0-7) DIGIT ONLY **** n");
exit();
}
while(oct!=0)
{ int mul =pow(8,i);
a=oct%10;
decimal+=a*mul;
i++;
// printf(" decimal digit after step %d is %d",i-1,decimal);
oct=oct/10;
}
printf(" $$$$$vREQUIRED DECIMAL EQIVALENT IS %d $$$$n",decimal);
getch();
}
• q2: Write an algorithm and its corresponding C program to illustrate an ATM money withdrawal operation from user’s savings’ account.
•
• code:
• #include<stdio.h>
• unsigned long AMOUNT=5000,DEPOSIT,WITHDRAW;
• int CHOICE,PIN,K,TRY=0;
• char TRANSACTION='Y';
• void main()
• {
• clrscr();
• if(PIN!= 1000)
• {
• printf("n _______WELCOME TO RBL BANK_________ n");
• printf("nENTER YOUR PIN NUMBER :");
• scanf("%d",&PIN);
•
• }
• do
• {
• clrscr();
• printf("*****WELCOME TO XYZ BANK*****n");
• printf("1.WITHDRAW CASHn");
• printf("2.QUITn");
• printf("*****************************nn");
• printf("ENTER YOUR CHOICE : ");
• scanf("%d",&CHOICE);
• switch(CHOICE)
• {
•
• case 1:
• printf("nENTER THE AMOUNT TO WITHDRAW CASHn");
• scanf("%ld",&WITHDRAW);
• if(WITHDRAW%100 != 0)
• {
• printf("nPLEASE ENTER THE AMOUNT IN MULTIPLIES OF 100n");
• }
• else if(WITHDRAW>(AMOUNT-1000))
• {
• printf("nINSUFFICIENT BALANCEn");
• }
• else
• {
• AMOUNT = AMOUNT-WITHDRAW;
• printf("nPLEASE COLLECT CASHn");
• printf("nYOUR CURRENT BALANCE IS %ldn",AMOUNT);
• }
• break;
•
• case 2:
• printf("nTHANK YOU FOR USING THIS ATMn");
• break;
• default :
• printf("nINVALID CHOICEn");
• }
• printf("nnDO YOU WISH TO DO ANOTHER TRANSCACTION?(Y/N): ");
• fflush(stdin);
• scanf("%c",&TRANSACTION);
• }while(TRANSACTION=='Y' || TRANSACTION=='y');
• printf("nTHANK YOU FOR USING THIS ATMn");
• getch();
• }
• algorithm:
• 1.set minimum amount(5000 for example).
• 2.declare withdraw argument.
• display "welcome to rbl bank "
• 3.enter a valid pin
• 4.do
• enter amount to withdraw
• IF(withdraw % 100!=0)
• plz enter amount in multiple of 100
• ELSE IF(WITHDRAW>(AMOUNT-1000)
• display "INSUFFICIENT BALANCE"
• ELSE
• AMOUNT = AMOUNT-WITHDRAW;
• display "PLEASE COLLECT CASH "
• DO YOU WISH TO DO ANOTHER TRANSCACTION?(Y/N)
•
•
• 5.while(TRANSACTION=='Y' ) continue from step 4.
• 6.THANK YOU FOR USING THIS ATM
•
• QUESTION 3:
• Write a program to find the largest element in an array using Recursion
• CODE:
• #include<stdio.h>
• #define MAX_S 1000
• int largest(int arr[],int position,int lar);
• int la,result;
• int main()
• {
• int arr[ MAX_S ];
• int n,i;
• printf(" ENTER SIZE OF ARRAY n");
• scanf(" %d ",&n);
•
• printf("ENTER ELEMNENTS OF ARRAY n");
•
• for(i=0;i<n;i++)
• { scanf("%d ",&arr[i]);
• }
• la=arr[0];
• result=largest(arr,n-1,la);
• printf(" +++++LARGEST ELEMENT IS %d++++ ",result);
•
•
• return 0;
• }
• int largest(int arr[],int position,int lar)
• {
• if(position==0) return lar;
• if(arr[position]>lar)
• { lar=arr[position];
•
•
• return largest(arr,position-1,lar);
• }
• return lar;
• }
• QUESTION 4: Write a C program to separate even and odd numbers of an array and put them in
two separate arrays.
•
• CODE:
• #include<stdio.h>
• # define max_size 1000
• void main()
• {
• int array[max_size];
• int even[max_size];
• int odd[max_size];
• int i,n;
• int e=0,o=0;
•
• printf("enter size of array");
• scanf("%d",&n);
•
• printf("entered size %d n",n);
• printf("enter element in the array ");
• for(i=0;i<=n-1;i++)
• {
• scanf("%d",&array[i]);
• }
•
•
• for(i=0;i<n;i++)
• {
• if(array[i]%2==0)
• {
• even[e]=array[i];
• e++;
• }
• else
• {
• odd[o]=array[i];
• o++;
• }
• }
•
• printf(" n EVEN ARRAY ") ;
•
• for(i=0;i<=e-1;i++)
• {
• printf(" %d n",even[i]);
• }
•
•
• printf(" n ODD ARRAY ");
•
• for(i=0;i<=o-1;i++)
• {
• printf(" %d n",odd[i]);
• }
•
• getch();
• }
• Question 5; Write a C program to determine a given matrix is a sparse matrix
• Code:
• #include <stdio.h>
•
•
• int array[10][10];
• int i, j, m, n;
• int counter = 0;
• void main()
• {
• clrscr();
• printf("Enter the order of the matix n");
• scanf("%d %d", &m, &n);
• printf("Enter the co-efficients of the matix n");
• for (i = 0; i < m; ++i)
• {
• for (j = 0; j < n; ++j)
• {
• scanf("%d", &array[i][j]);
• if (array[i][j] == 0)
• {
• ++counter;
• }
• }
• }
• if (counter > ((m * n) / 2))
• {
• printf("The given matrix is sparse matrix n");
• }
• else
• printf("The given matrix is not a sparse matrix n");
• printf("There are %d number of zeros", counter);
• getch();
• }
• Question 6:
•
• Write an interactive C program to calculate the sum of array elements using pointer
• Code:
• #include<stdio.h>
• #define MAX 100
• int array[MAX];
• int *ptr;
• int i,n;
• int sum=0;
• void main()
• {
• clrscr();
• printf(" ENTER SIZE OF ARRAY n");
• scanf("%d",&n);
•
• printf("ENTER ELEMENTS OF ARRAY n");
• for(i=0;i<n;i++)
• { scanf("%d",&array[i]);
• }
• ptr=array;
• for(i=0;i<=n-1;i++)
• {
• sum+=*ptr;
• ptr++;
• }
• printf("n REQUIRED SUM IS %d",sum);
• getch();
• }
• Question 7: Write an interactive C program to append the contents of a file at the end of another file without
using any built-in functions.
•
• #include <stdio.h>
• #include <stdlib.h>
•
• main()
• {
• FILE *fsring1, *fsring2, *ftemp;
• char ch, file1[20], file2[20], file3[20];
•
• printf("Enter name of first file ");
• gets(file1);
• printf("Enter name of second file ");
• gets(file2);
• printf("Enter name to store merged file ");
• gets(file3);
• fsring1 = fopen(file1, "r");
• fsring2 = fopen(file2, "r");
• if (fsring1 == NULL || fsring2 == NULL)
• {
• perror("Error has occured");
• printf("Press any key to exit...n");
• exit(EXIT_FAILURE);
• }
• ftemp = fopen(file3, "w");
• if (ftemp == NULL)
• {
• perror("Error has occures");
• printf("Press any key to exit...n");
• exit(EXIT_FAILURE);
• }
• while ((ch = fgetc(fsring1)) != EOF)
• fputc(ch, ftemp);
• while ((ch = fgetc(fsring2) ) != EOF)
• fputc(ch, ftemp);
• printf("Two files merged %s successfully.n", file3);
• fclose(fsring1);
• fclose(fsring2);
• fclose(ftemp);
• return 0;
• }
• 8. Write an interactive C program to create a file containing student’s records and also give a provision to
update/modify the records too.
• Code:
• #include<stdio.h>
• #include<conio.h>
• #include<process.h>
• typedef struct student {
• int roll;
• char name[20];
• float marks;
• }3 stud;
• void sort(int n)
• {
• FILE *fp_index, *fp_record;
• int i, j, r1, r2, r3;
• stud s1, s2, s3;
• fp_index = fopen("index.txt", "r+b");
• fp_record = fopen("record.txt", "r+b");
• for (i = 0; i < n - 1; i++)
• {
• for (j = 0; j < n - 1; j++)
• {
• fseek(fp_record, sizeof(s1) * j, SEEK_SET);
• fseek(fp_index, sizeof(int) * j, SEEK_SET);
• fread(&r1, sizeof(int), 1, fp_index);
• fread(&r2, sizeof(int), 1, fp_index);
• if (r1 > r2) //swap record and index
• {
• fread(&s1, sizeof(s1), 1, fp_record);
• fread(&s2, sizeof(s2), 1, fp_record);
• fseek(fp_record, (sizeof(s1)) * j, SEEK_SET);
• fseek(fp_index, (sizeof(int)) * j, SEEK_SET);
• fwrite(&r2, sizeof(int), 1, fp_index);
• fwrite(&r1, sizeof(int), 1, fp_index);
• fwrite(&s2, sizeof(s1), 1, fp_record);
• fwrite(&s1, sizeof(s1), 1, fp_record);
• }
• }
• }
• fclose(fp_index);
• fclose(fp_record);
• }
• void add()
• {
• int n = 0;
• float temp;
• FILE *fp_index, *fp_record;
• stud s1;
• fp_index = fopen("index.txt", "r+b");
• fp_record = fopen("record.txt", "r+b");
• printf("nnEnter roll no: ");
• scanf("%d", &s1.roll);
• printf("nEnter Name: ");
• scanf("%s", s1.name);
• printf("nEnter marks: ");
• scanf("%f", &temp);
• s1.marks = temp;
• fseek(fp_record, 0, SEEK_END);
• if (fwrite(&s1, sizeof(s1), 1, fp_record))
• {
• fseek(fp_index, 0, SEEK_END);
• fwrite(&(s1.roll), sizeof(int), 1, fp_index);
• }
• else
• {
• printf("nnCould NOT add !!!");
• }
• rewind(fp_index);
• while ((fread(&s1, sizeof(int), 1, fp_index)))
• FILE *fp;
• stud s1, s2;
• int choice, roll_no;
• clrscr();
• fp = fopen("record.txt", "a+b");
• fclose(fp);
• fp = fopen("temp.txt", "a+b");
• fclose(fp);
• fp = fopen("index.txt", "a+b");
• fclose(fp);
• while (1)
• {printf("STUDENT DATABASE n");
• printf("nn1:Add 2:Display 3:Search 4:Edit 5:Delete 6:Exit nn enter ur choice n");
•
• scanf("%d", &choice);
• switch (choice)
• {
• case 1:
• add();
• break;
• case 2:
• display();
• break;
• case 3:
• printf("nnEnter Roll No To Search Record : ");
• scanf("%d", &roll_no);
• search(roll_no);
• break;
• case 4:
• printf("nnEnter Roll No To Edit Record : ");
• scanf("%d", &roll_no);
• edit(roll_no);
• break;
• case 5:
• printf("nnEnter Roll No To Delete Record : ");
• scanf("%d", &roll_no);
• delet(&s2, roll_no);
• break;
• case 6:
• exit(0);
• default:
• printf("nnInvalid choice !!!");
• }
• }
• getch();
• }
•
•
•
•
•
THANKYOU

Mais conteúdo relacionado

Mais procurados

Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka StreamsAlexey Romanchuk
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical filePranav Ghildiyal
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31Mahmoud Samir Fayed
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diplomamustkeem khan
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parserkamaelian
 
The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181Mahmoud Samir Fayed
 
Simple API for XML
Simple API for XMLSimple API for XML
Simple API for XMLguest2556de
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diplomamustkeem khan
 
Rx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com ObservablesRx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com Observableslokimad
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3Matthew Turland
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
Functional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-StreamFunctional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-StreamAdil Akhter
 

Mais procurados (19)

Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka Streams
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Command Liner with Scala
Command Liner with ScalaCommand Liner with Scala
Command Liner with Scala
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181
 
Simple API for XML
Simple API for XMLSimple API for XML
Simple API for XML
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
 
Rx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com ObservablesRx-Java - Como compor sua aplicacao com Observables
Rx-Java - Como compor sua aplicacao com Observables
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
Functional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-StreamFunctional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-Stream
 

Semelhante a IGNOU SOLVED ASSIGNMENT 2018 MCS-011 PROBLEM SOLVING AND PROGRAMMING

Semelhante a IGNOU SOLVED ASSIGNMENT 2018 MCS-011 PROBLEM SOLVING AND PROGRAMMING (20)

Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)
 
Arrays matrix 2020 ab
Arrays matrix 2020 abArrays matrix 2020 ab
Arrays matrix 2020 ab
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
Logic development
Logic developmentLogic development
Logic development
 
C
CC
C
 
Leniar datastructure
Leniar datastructureLeniar datastructure
Leniar datastructure
 
Vcs16
Vcs16Vcs16
Vcs16
 
Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
C programs
C programsC programs
C programs
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Python Fundamentals - Basic
Python Fundamentals - BasicPython Fundamentals - Basic
Python Fundamentals - Basic
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
Pnno
PnnoPnno
Pnno
 
Czzawk
CzzawkCzzawk
Czzawk
 

Último

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Último (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

IGNOU SOLVED ASSIGNMENT 2018 MCS-011 PROBLEM SOLVING AND PROGRAMMING

  • 1. IGNOU SOLVED ASSIGNMENT 2018 MCS-011 PROBLEM SOLVING AND PROGRAMMING
  • 2. • QUESTION1. convert octal to decimal • ANSWER: • The Octal Number System is a type of computer and digital numbering system which uses the Base-8 system. • Octal numbers therefore have a range of just “8” digits, (0, 1, 2, 3, 4, 5, 6, 7) making them a Base-8 numbering system. • Then the main characteristics of an Octal Numbering System is that there are only 8 distinct counting digits from 0 to 7 with • each digit having a weight or value of just 8 starting from the least significant bit (LSB). • •
  • 3. • program: • #include<stdio.h> • #include<math.h> • • int oct; • int decimal=0; • int a; • int i=0; • • void main() • { clrscr(); • printf("ENTER A OCTAL NUMBER:n"); • scanf("%d",&oct); • if(oct==8 ||oct==9) • {
  • 4. printf("**** IT IS NOT AN OCTAL NUMBER KINDLY USE(0-7) DIGIT ONLY **** n"); exit(); } while(oct!=0) { int mul =pow(8,i); a=oct%10; decimal+=a*mul; i++; // printf(" decimal digit after step %d is %d",i-1,decimal); oct=oct/10; } printf(" $$$$$vREQUIRED DECIMAL EQIVALENT IS %d $$$$n",decimal); getch(); }
  • 5. • q2: Write an algorithm and its corresponding C program to illustrate an ATM money withdrawal operation from user’s savings’ account. • • code: • #include<stdio.h> • unsigned long AMOUNT=5000,DEPOSIT,WITHDRAW; • int CHOICE,PIN,K,TRY=0; • char TRANSACTION='Y'; • void main() • { • clrscr(); • if(PIN!= 1000) • { • printf("n _______WELCOME TO RBL BANK_________ n"); • printf("nENTER YOUR PIN NUMBER :"); • scanf("%d",&PIN); • • } • do • { • clrscr(); • printf("*****WELCOME TO XYZ BANK*****n"); • printf("1.WITHDRAW CASHn"); • printf("2.QUITn"); • printf("*****************************nn"); • printf("ENTER YOUR CHOICE : "); • scanf("%d",&CHOICE); • switch(CHOICE) • { • • case 1: • printf("nENTER THE AMOUNT TO WITHDRAW CASHn"); • scanf("%ld",&WITHDRAW); • if(WITHDRAW%100 != 0) • { • printf("nPLEASE ENTER THE AMOUNT IN MULTIPLIES OF 100n"); • }
  • 6. • else if(WITHDRAW>(AMOUNT-1000)) • { • printf("nINSUFFICIENT BALANCEn"); • } • else • { • AMOUNT = AMOUNT-WITHDRAW; • printf("nPLEASE COLLECT CASHn"); • printf("nYOUR CURRENT BALANCE IS %ldn",AMOUNT); • } • break; • • case 2: • printf("nTHANK YOU FOR USING THIS ATMn"); • break; • default : • printf("nINVALID CHOICEn"); • } • printf("nnDO YOU WISH TO DO ANOTHER TRANSCACTION?(Y/N): "); • fflush(stdin); • scanf("%c",&TRANSACTION); • }while(TRANSACTION=='Y' || TRANSACTION=='y'); • printf("nTHANK YOU FOR USING THIS ATMn"); • getch(); • }
  • 7. • algorithm: • 1.set minimum amount(5000 for example). • 2.declare withdraw argument. • display "welcome to rbl bank " • 3.enter a valid pin • 4.do • enter amount to withdraw • IF(withdraw % 100!=0) • plz enter amount in multiple of 100 • ELSE IF(WITHDRAW>(AMOUNT-1000) • display "INSUFFICIENT BALANCE" • ELSE • AMOUNT = AMOUNT-WITHDRAW; • display "PLEASE COLLECT CASH " • DO YOU WISH TO DO ANOTHER TRANSCACTION?(Y/N) • • • 5.while(TRANSACTION=='Y' ) continue from step 4. • 6.THANK YOU FOR USING THIS ATM •
  • 8. • QUESTION 3: • Write a program to find the largest element in an array using Recursion • CODE: • #include<stdio.h> • #define MAX_S 1000 • int largest(int arr[],int position,int lar); • int la,result; • int main() • { • int arr[ MAX_S ]; • int n,i; • printf(" ENTER SIZE OF ARRAY n"); • scanf(" %d ",&n); • • printf("ENTER ELEMNENTS OF ARRAY n"); • • for(i=0;i<n;i++) • { scanf("%d ",&arr[i]); • } • la=arr[0];
  • 9. • result=largest(arr,n-1,la); • printf(" +++++LARGEST ELEMENT IS %d++++ ",result); • • • return 0; • } • int largest(int arr[],int position,int lar) • { • if(position==0) return lar; • if(arr[position]>lar) • { lar=arr[position]; • • • return largest(arr,position-1,lar); • } • return lar; • }
  • 10. • QUESTION 4: Write a C program to separate even and odd numbers of an array and put them in two separate arrays. • • CODE: • #include<stdio.h> • # define max_size 1000 • void main() • { • int array[max_size]; • int even[max_size]; • int odd[max_size]; • int i,n; • int e=0,o=0; • • printf("enter size of array"); • scanf("%d",&n); • • printf("entered size %d n",n); • printf("enter element in the array "); • for(i=0;i<=n-1;i++) • {
  • 11. • scanf("%d",&array[i]); • } • • • for(i=0;i<n;i++) • { • if(array[i]%2==0) • { • even[e]=array[i]; • e++; • } • else • { • odd[o]=array[i]; • o++; • } • } • • printf(" n EVEN ARRAY ") ; • • for(i=0;i<=e-1;i++) • { • printf(" %d n",even[i]); • } • • • printf(" n ODD ARRAY "); • • for(i=0;i<=o-1;i++) • { • printf(" %d n",odd[i]); • } • • getch(); • }
  • 12. • Question 5; Write a C program to determine a given matrix is a sparse matrix • Code: • #include <stdio.h> • • • int array[10][10]; • int i, j, m, n; • int counter = 0; • void main() • { • clrscr(); • printf("Enter the order of the matix n"); • scanf("%d %d", &m, &n); • printf("Enter the co-efficients of the matix n"); • for (i = 0; i < m; ++i) • { • for (j = 0; j < n; ++j) • { • scanf("%d", &array[i][j]); • if (array[i][j] == 0) • { • ++counter; • } • } • } • if (counter > ((m * n) / 2)) • { • printf("The given matrix is sparse matrix n"); • } • else • printf("The given matrix is not a sparse matrix n"); • printf("There are %d number of zeros", counter); • getch(); • }
  • 13. • Question 6: • • Write an interactive C program to calculate the sum of array elements using pointer • Code: • #include<stdio.h> • #define MAX 100 • int array[MAX]; • int *ptr; • int i,n; • int sum=0; • void main() • { • clrscr(); • printf(" ENTER SIZE OF ARRAY n"); • scanf("%d",&n); • • printf("ENTER ELEMENTS OF ARRAY n"); • for(i=0;i<n;i++) • { scanf("%d",&array[i]); • } • ptr=array; • for(i=0;i<=n-1;i++) • { • sum+=*ptr; • ptr++; • } • printf("n REQUIRED SUM IS %d",sum); • getch(); • }
  • 14. • Question 7: Write an interactive C program to append the contents of a file at the end of another file without using any built-in functions. • • #include <stdio.h> • #include <stdlib.h> • • main() • { • FILE *fsring1, *fsring2, *ftemp; • char ch, file1[20], file2[20], file3[20]; • • printf("Enter name of first file "); • gets(file1); • printf("Enter name of second file "); • gets(file2); • printf("Enter name to store merged file "); • gets(file3); • fsring1 = fopen(file1, "r"); • fsring2 = fopen(file2, "r"); • if (fsring1 == NULL || fsring2 == NULL) • { • perror("Error has occured"); • printf("Press any key to exit...n"); • exit(EXIT_FAILURE);
  • 15. • } • ftemp = fopen(file3, "w"); • if (ftemp == NULL) • { • perror("Error has occures"); • printf("Press any key to exit...n"); • exit(EXIT_FAILURE); • } • while ((ch = fgetc(fsring1)) != EOF) • fputc(ch, ftemp); • while ((ch = fgetc(fsring2) ) != EOF) • fputc(ch, ftemp); • printf("Two files merged %s successfully.n", file3); • fclose(fsring1); • fclose(fsring2); • fclose(ftemp); • return 0; • }
  • 16. • 8. Write an interactive C program to create a file containing student’s records and also give a provision to update/modify the records too. • Code: • #include<stdio.h> • #include<conio.h> • #include<process.h> • typedef struct student { • int roll; • char name[20]; • float marks; • }3 stud; • void sort(int n) • { • FILE *fp_index, *fp_record; • int i, j, r1, r2, r3; • stud s1, s2, s3; • fp_index = fopen("index.txt", "r+b"); • fp_record = fopen("record.txt", "r+b"); • for (i = 0; i < n - 1; i++) • {
  • 17. • for (j = 0; j < n - 1; j++) • { • fseek(fp_record, sizeof(s1) * j, SEEK_SET); • fseek(fp_index, sizeof(int) * j, SEEK_SET); • fread(&r1, sizeof(int), 1, fp_index); • fread(&r2, sizeof(int), 1, fp_index); • if (r1 > r2) //swap record and index • { • fread(&s1, sizeof(s1), 1, fp_record); • fread(&s2, sizeof(s2), 1, fp_record); • fseek(fp_record, (sizeof(s1)) * j, SEEK_SET); • fseek(fp_index, (sizeof(int)) * j, SEEK_SET); • fwrite(&r2, sizeof(int), 1, fp_index); • fwrite(&r1, sizeof(int), 1, fp_index); • fwrite(&s2, sizeof(s1), 1, fp_record); • fwrite(&s1, sizeof(s1), 1, fp_record); • } • } • } • fclose(fp_index); • fclose(fp_record); • } • void add() • { • int n = 0; • float temp; • FILE *fp_index, *fp_record; • stud s1; • fp_index = fopen("index.txt", "r+b"); • fp_record = fopen("record.txt", "r+b"); • printf("nnEnter roll no: "); • scanf("%d", &s1.roll); • printf("nEnter Name: "); • scanf("%s", s1.name); • printf("nEnter marks: "); • scanf("%f", &temp); • s1.marks = temp; • fseek(fp_record, 0, SEEK_END); • if (fwrite(&s1, sizeof(s1), 1, fp_record)) • { • fseek(fp_index, 0, SEEK_END); • fwrite(&(s1.roll), sizeof(int), 1, fp_index); • } • else • { • printf("nnCould NOT add !!!"); • } • rewind(fp_index); • while ((fread(&s1, sizeof(int), 1, fp_index)))
  • 18. • FILE *fp; • stud s1, s2; • int choice, roll_no; • clrscr(); • fp = fopen("record.txt", "a+b"); • fclose(fp); • fp = fopen("temp.txt", "a+b"); • fclose(fp); • fp = fopen("index.txt", "a+b"); • fclose(fp); • while (1) • {printf("STUDENT DATABASE n"); • printf("nn1:Add 2:Display 3:Search 4:Edit 5:Delete 6:Exit nn enter ur choice n"); • • scanf("%d", &choice); • switch (choice) • { • case 1: • add(); • break; • case 2: • display(); • break; • case 3:
  • 19. • printf("nnEnter Roll No To Search Record : "); • scanf("%d", &roll_no); • search(roll_no); • break; • case 4: • printf("nnEnter Roll No To Edit Record : "); • scanf("%d", &roll_no); • edit(roll_no); • break; • case 5: • printf("nnEnter Roll No To Delete Record : "); • scanf("%d", &roll_no); • delet(&s2, roll_no); • break; • case 6: • exit(0); • default: • printf("nnInvalid choice !!!"); • } • } • getch(); • } • • • • •