SlideShare a Scribd company logo
1 of 10
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
 Findthe error inthe program and solve itandwrite downthe solutionofit.
Program 1:
#include<stdio.h>
#include<conio.h>
void main()
{
int a=100,b=200,c=300;
int p*=&a;
clrscr();
printf("n%u %d %u",&a,&b,&c);
printf("nP=%u%f",p,*p);
p--;
printf("nP=%u%u",p,*p);
p--;
printf("nP=%u%u",p,*p);
geteh();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 2:
#include<stdio.h>
#include<conio.h>
void main()
{
int idx,a[],n=5;
clrscr();
for(i=0;i<5;i++)
{
printf("nEnt a[%d] : ",i);
scanf("%d",&a[i]);
}
printf("nEnt element number to delet : ");
scanf("%d",&idx);
for(i=idx;i<n-1;i++)
{
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
a[1]=a[i+i];
}
for(i=0;i<n-1;i++)
{
printf("na[%u] : %d",i,a[i]);
}
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 3:
#include<stdoi.h>
#include<conio.h>
int fact(int);
void main()
{
int x=10;
igned long f;
clrscr();
f=fact(x);
printf("nFactorial of %d is : %lu",x,f);
getch();
}
int fact(int x)
{
int i;
unsigned long p=1;
for(i=x;i>0:i--);
{
p=p*x;
}
returnp;
}
Solve Error:
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 4:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[],i,ixd;
clrscr();
for(i=0;i<10;i++)
{
printf("nEnt [%d] : ",i);
scanf("%d",&a[i]);
}
printf("nEnt index no. to change value : ");
scanf("%d",&idx);
printf("nEnt new value of a[%d] : ",idx);
scanf("%f",&a[idx]);
for(i=0;i<10;i++)
{
printf("nnvalue of a[%d] : %d",i,a[i]);
}
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 5:
#include<stdio.h>
#include<conio.h>
void main()
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
{
int x=2,f,y=3;
clrscr();
f=paw(x,y);
printf("Ans is : %c",x);
getch();
}
int pow(int x,int y)
{
int p=1,i;
for(i=y;i>0;i--)
{
p=p*x;
}
returnp;
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 6:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5]
int *p;
clrscr();
for(i=0;i<5;i++)
{
printf("nEnt a[%d] : ",i);
scanf("%d",&a[i]);
}
for(i=0;i<5;i++)
{
printf("naddress of a[%d] ; %d",i,p);
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
p--;
}
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 7:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,s,j;
clrscr();
for(i=0;i<5;i++)
{
printf("nEnt a[%f] : ",i);
scanf("%d",&a[i]);
}
for(i=0:i<5:i++)
{
printf("nvalue of a[%d] : %d",i,a[i]);
}
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j--)
{
if(a[i]<a[j])
{
s=a[j];
a[j]=a[i];
a[i]=s;
}
}
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
}
for(i=0;i<5;i++)
{
printf("nnew value of a[%d] : %d",i,a[i]);
}
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 8:
#include<stdio.h>
#include<conio.h>
struct student
{
int rn;
char nm[20];
}
void main()
{
struct student x;
clrscr();
printf("nEnt Roll No : ");
scanf("%d",&x.rn);
printf("nEnt Name : ");
scanf("%s",&x,nm);
clrscr();
printf("nStudent Roll No is : %d",x.rn);
printf("nStudent Name is : %s",x.nm);
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
Program 9:
#include<stdio.h>
#include<conio.h>
void sum(int,int);
void moin()
{
int x=10,y=20;
sum(10,20);
}
void sum(int x,int y)
{
int z;
clrscr();
z=x+y;
printf("Sum is : %d",z);
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 10:
#include<stdio.h>
#include<conio.h>
unoionstudent
{
int rn;
char nm[20];
};
void main()
{
union student x;
clrscr();
printf("Ent roll no : ");
scanf("%d",&x.nm);
printf("Ent name : ");
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
scanf("%d",&x.nm);
clrscr();
printf("nRoll no : %dnname : %s",x.rn,x.nm);
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 11:
#include <stdio.h>
#include <conio.h>
void main ()
{
int i , k;
int set1[2][2]= { {5,8},{2,5} } ;
int set2[2][2]= { {3,7},{4,9} } ;
int multi[2][2] ;
clrscr () ;
printf ("Values of set1 :n") ;
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<2 ; j++)
printf ("%dt",set1[i][j]) ;
}
printf ("nnValues of set2 :n") ;
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<2 ; j++)
printf ("%dt",set2[i][j]) ;
}
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<2 ; j++)
multi[i][j] = set1[i][j] * set2[i][k] ;
}
printf ("nnThe result of multiplicationis :n") ;
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<2 ; j++)
printf ("%dt",multi[i][j]) ;
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
}
getch() ;
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 12:
#include <stdio.h>
#include <conio.h>
char line[40]
void main ()
{
int length ;
int calculate_length() ;
clrscr () ;
printf ("Enter a string : n") ;
gets (line) ;
length = calculate_length() ;
printf ("nThe stringlength is %c. n",length) ;
getch() ;
}
int calculate_length()
{
int count = 0 ;
while (line[count]!= '0')
count++ ;
return(count) ;
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________
Program 13:
INOVACE ’14
Software Debugging
AARSH MAHAVIDYALAYA
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[50],ch,a1[50];
doubale i,j;
clrscr();
puts("Ent any string");
gets(a);
strcpy(a1,strupr(a));
for(i=0;a1[i]!='0';i++);
{
for(j=i+1;a1[j]!='0';j++)
{
if(a1[i]>a1[j])
{
ch=a1[j];
a1[j]=a1[i];
a1[i]=ch;
}
}
}
strcpy(a,strlwr(a1));
puts(a1);
getch();
}
Solve Error:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
______________________________

More Related Content

Viewers also liked

Viewers also liked (7)

e.portfolio
e.portfolioe.portfolio
e.portfolio
 
Pln 2
Pln 2Pln 2
Pln 2
 
My ple2
My ple2My ple2
My ple2
 
Ajedrez 2014
Ajedrez 2014Ajedrez 2014
Ajedrez 2014
 
Carlos polistico garcía
Carlos polistico garcíaCarlos polistico garcía
Carlos polistico garcía
 
Web制作初心者でもわかるSchema.org
Web制作初心者でもわかるSchema.orgWeb制作初心者でもわかるSchema.org
Web制作初心者でもわかるSchema.org
 
Delco Pflex Introductions 2014-2015
Delco Pflex Introductions 2014-2015Delco Pflex Introductions 2014-2015
Delco Pflex Introductions 2014-2015
 

Similar to Software Debugging Problems and Solutions

You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docxajoy21
 
job analysis questionnaire
job analysis questionnairejob analysis questionnaire
job analysis questionnaireHarve Abella
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
Vilka är drivkrafterna bakom social shopping? - Mari-Linn Stenlund
Vilka är drivkrafterna bakom social shopping? - Mari-Linn StenlundVilka är drivkrafterna bakom social shopping? - Mari-Linn Stenlund
Vilka är drivkrafterna bakom social shopping? - Mari-Linn StenlundSearchHeroes
 
Ficha tecnica compuayudas mayo
Ficha tecnica compuayudas mayoFicha tecnica compuayudas mayo
Ficha tecnica compuayudas mayoluisbes
 
Hrishikesh Choudhari - Overview Of Cracks
Hrishikesh Choudhari - Overview Of CracksHrishikesh Choudhari - Overview Of Cracks
Hrishikesh Choudhari - Overview Of CracksHrishikesh Choudhari
 
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015Sergii Khomenko
 
Puppet Camp London 2015 - Helping Data Teams with Puppet
Puppet Camp London 2015 - Helping Data Teams with PuppetPuppet Camp London 2015 - Helping Data Teams with Puppet
Puppet Camp London 2015 - Helping Data Teams with PuppetPuppet
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
SAP BPC on HANA Environment Security Management Implementation Guide
SAP BPC on HANA Environment Security Management Implementation GuideSAP BPC on HANA Environment Security Management Implementation Guide
SAP BPC on HANA Environment Security Management Implementation GuideCloneskills
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Byrne Reese
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Compare Infobase Limited
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3Javier Eguiluz
 
webdynpro Popup Open
webdynpro Popup Openwebdynpro Popup Open
webdynpro Popup Openjung_se_hun
 

Similar to Software Debugging Problems and Solutions (20)

Lab 1
Lab 1Lab 1
Lab 1
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
CA_TST2
CA_TST2CA_TST2
CA_TST2
 
You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docx
 
job analysis questionnaire
job analysis questionnairejob analysis questionnaire
job analysis questionnaire
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
Vilka är drivkrafterna bakom social shopping? - Mari-Linn Stenlund
Vilka är drivkrafterna bakom social shopping? - Mari-Linn StenlundVilka är drivkrafterna bakom social shopping? - Mari-Linn Stenlund
Vilka är drivkrafterna bakom social shopping? - Mari-Linn Stenlund
 
Ficha tecnica compuayudas mayo
Ficha tecnica compuayudas mayoFicha tecnica compuayudas mayo
Ficha tecnica compuayudas mayo
 
Hrishikesh Choudhari - Overview Of Cracks
Hrishikesh Choudhari - Overview Of CracksHrishikesh Choudhari - Overview Of Cracks
Hrishikesh Choudhari - Overview Of Cracks
 
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015
 
Puppet Camp London 2015 - Helping Data Teams with Puppet
Puppet Camp London 2015 - Helping Data Teams with PuppetPuppet Camp London 2015 - Helping Data Teams with Puppet
Puppet Camp London 2015 - Helping Data Teams with Puppet
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
SAP BPC on HANA Environment Security Management Implementation Guide
SAP BPC on HANA Environment Security Management Implementation GuideSAP BPC on HANA Environment Security Management Implementation Guide
SAP BPC on HANA Environment Security Management Implementation Guide
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
20 Jo P Aug 08
20 Jo P Aug 0820 Jo P Aug 08
20 Jo P Aug 08
 
Input output
Input outputInput output
Input output
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Symfony 1, mi viejo amigo
Symfony 1, mi viejo amigoSymfony 1, mi viejo amigo
Symfony 1, mi viejo amigo
 
webdynpro Popup Open
webdynpro Popup Openwebdynpro Popup Open
webdynpro Popup Open
 

Recently uploaded

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
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
 
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
 
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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
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
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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
 

Recently uploaded (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
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...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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 ...
 
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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
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
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 

Software Debugging Problems and Solutions

  • 1. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA  Findthe error inthe program and solve itandwrite downthe solutionofit. Program 1: #include<stdio.h> #include<conio.h> void main() { int a=100,b=200,c=300; int p*=&a; clrscr(); printf("n%u %d %u",&a,&b,&c); printf("nP=%u%f",p,*p); p--; printf("nP=%u%u",p,*p); p--; printf("nP=%u%u",p,*p); geteh(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 2: #include<stdio.h> #include<conio.h> void main() { int idx,a[],n=5; clrscr(); for(i=0;i<5;i++) { printf("nEnt a[%d] : ",i); scanf("%d",&a[i]); } printf("nEnt element number to delet : "); scanf("%d",&idx); for(i=idx;i<n-1;i++) {
  • 2. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA a[1]=a[i+i]; } for(i=0;i<n-1;i++) { printf("na[%u] : %d",i,a[i]); } getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 3: #include<stdoi.h> #include<conio.h> int fact(int); void main() { int x=10; igned long f; clrscr(); f=fact(x); printf("nFactorial of %d is : %lu",x,f); getch(); } int fact(int x) { int i; unsigned long p=1; for(i=x;i>0:i--); { p=p*x; } returnp; } Solve Error:
  • 3. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 4: #include<stdio.h> #include<conio.h> void main() { int a[],i,ixd; clrscr(); for(i=0;i<10;i++) { printf("nEnt [%d] : ",i); scanf("%d",&a[i]); } printf("nEnt index no. to change value : "); scanf("%d",&idx); printf("nEnt new value of a[%d] : ",idx); scanf("%f",&a[idx]); for(i=0;i<10;i++) { printf("nnvalue of a[%d] : %d",i,a[i]); } getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 5: #include<stdio.h> #include<conio.h> void main()
  • 4. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA { int x=2,f,y=3; clrscr(); f=paw(x,y); printf("Ans is : %c",x); getch(); } int pow(int x,int y) { int p=1,i; for(i=y;i>0;i--) { p=p*x; } returnp; } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 6: #include<stdio.h> #include<conio.h> void main() { int a[5] int *p; clrscr(); for(i=0;i<5;i++) { printf("nEnt a[%d] : ",i); scanf("%d",&a[i]); } for(i=0;i<5;i++) { printf("naddress of a[%d] ; %d",i,p);
  • 5. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA p--; } getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 7: #include<stdio.h> #include<conio.h> void main() { int a[5],i,s,j; clrscr(); for(i=0;i<5;i++) { printf("nEnt a[%f] : ",i); scanf("%d",&a[i]); } for(i=0:i<5:i++) { printf("nvalue of a[%d] : %d",i,a[i]); } for(i=0;i<5;i++) { for(j=i+1;j<5;j--) { if(a[i]<a[j]) { s=a[j]; a[j]=a[i]; a[i]=s; } }
  • 6. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA } for(i=0;i<5;i++) { printf("nnew value of a[%d] : %d",i,a[i]); } getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 8: #include<stdio.h> #include<conio.h> struct student { int rn; char nm[20]; } void main() { struct student x; clrscr(); printf("nEnt Roll No : "); scanf("%d",&x.rn); printf("nEnt Name : "); scanf("%s",&x,nm); clrscr(); printf("nStudent Roll No is : %d",x.rn); printf("nStudent Name is : %s",x.nm); getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________
  • 7. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA Program 9: #include<stdio.h> #include<conio.h> void sum(int,int); void moin() { int x=10,y=20; sum(10,20); } void sum(int x,int y) { int z; clrscr(); z=x+y; printf("Sum is : %d",z); getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 10: #include<stdio.h> #include<conio.h> unoionstudent { int rn; char nm[20]; }; void main() { union student x; clrscr(); printf("Ent roll no : "); scanf("%d",&x.nm); printf("Ent name : ");
  • 8. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA scanf("%d",&x.nm); clrscr(); printf("nRoll no : %dnname : %s",x.rn,x.nm); getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 11: #include <stdio.h> #include <conio.h> void main () { int i , k; int set1[2][2]= { {5,8},{2,5} } ; int set2[2][2]= { {3,7},{4,9} } ; int multi[2][2] ; clrscr () ; printf ("Values of set1 :n") ; for (i=0 ; i<2 ; i++) { for (j=0 ; j<2 ; j++) printf ("%dt",set1[i][j]) ; } printf ("nnValues of set2 :n") ; for (i=0 ; i<2 ; i++) { for (j=0 ; j<2 ; j++) printf ("%dt",set2[i][j]) ; } for (i=0 ; i<2 ; i++) { for (j=0 ; j<2 ; j++) multi[i][j] = set1[i][j] * set2[i][k] ; } printf ("nnThe result of multiplicationis :n") ; for (i=0 ; i<2 ; i++) { for (j=0 ; j<2 ; j++) printf ("%dt",multi[i][j]) ;
  • 9. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA } getch() ; } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 12: #include <stdio.h> #include <conio.h> char line[40] void main () { int length ; int calculate_length() ; clrscr () ; printf ("Enter a string : n") ; gets (line) ; length = calculate_length() ; printf ("nThe stringlength is %c. n",length) ; getch() ; } int calculate_length() { int count = 0 ; while (line[count]!= '0') count++ ; return(count) ; } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________ Program 13:
  • 10. INOVACE ’14 Software Debugging AARSH MAHAVIDYALAYA #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[50],ch,a1[50]; doubale i,j; clrscr(); puts("Ent any string"); gets(a); strcpy(a1,strupr(a)); for(i=0;a1[i]!='0';i++); { for(j=i+1;a1[j]!='0';j++) { if(a1[i]>a1[j]) { ch=a1[j]; a1[j]=a1[i]; a1[i]=ch; } } } strcpy(a,strlwr(a1)); puts(a1); getch(); } Solve Error: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ______________________________