Why do I get a Runtime exception?

faq
rte

#1

Why am i getting runtime exception?


#2

There are four types of Runtime exception, and you can see which one you are getting by hovering your mouse over the icon. You cannot know anything more specific; for example the exact Exception thrown in Java. Note that some errors could lead onto other errors, so even if you are getting one particular message, you should check each one separately.


#3

RE (NZEC).


#4

#include<stdio.h>
int main()
{
int c=0,p;
long int a[100], i,j,n,m;
scanf("%ld%ld",&n,&m);
for(i=0;i<n;i++)
{
scanf("%ld",&a*);
p=a*;
if(p%m==0)
{
c++;
}
}
printf("%d",c);
return 0;
}


#5

#include<stdio.h>
void display(int);
void main()
{int n;
scanf("%d
",&n);
display(n);
}
void display(int n)
{
int m,z[n],i,j=0;

for(i=0;i<n;i++)
{scanf("%d
“,&m);
if((m%100==m))
{z[j]=m;
j++;
}
}
for(i=0;i<j;i++)
{if(z*!=42)
printf(”%d
",z*);
else
break;
}
}


#6

#include<stdio.h>
int a[1000];
void main()
{
int t,i,j,s;
printf(“enter number of cases”);
scanf("%d",&t);
for(i=0;i<t;i++)
{
printf("
enter data");
scanf("%d",&a*);
}
printf("%d",t);
for(i=0;i<t;i++)
{
s=0;
if(a*!=0)
{
for(j=a*;j>0;j–)
{
if(a*%j==0)
s=s+j;
}
}
printf("
%d",s);
}
}


#7

#include<stdio.h>

int main()
{
int t;
printf("
enter the number of test case : “);
scanf(”%d",&t);
while(t>0)
{
int nbNote=0,amount=0;
int nb100=0,nb50=0,nb10=0,nb5=0,nb2=0,nb1=0;
printf("
enter the amount : “);
scanf(”%d",&amount);
if(amount%100>=0)
{
nb100=amount/100;
nbNote+=nb100;
amount-=(nb100100);
}
if(amount%50>=0)
{
nb50=amount/50;
nbNote+=nb50;
amount-=(nb50
50);
}
if(amount%10>=0)
{
nb10=amount/10;
nbNote+=nb10;
amount-=(nb1010);
}
if(amount%5>=0)
{
nb5=amount/5;
nbNote+=nb5;
amount-=(nb5
5);
}
if(amount%2>=0)
{
nb2=amount/2;
nbNote+=nb2;
amount-=(nb22);
}
if(amount%1>=0)
{
nb1=amount/1;
nbNote+=nb1;
amount-=(nb1
1);
}
printf("
number of notes = %d",nbNote);
t–;
}
return 0;
}


#8

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
scanf("%2d",&i);

while(i=!42)
{
printf("%2d",i);
scanf("%2d",&i);
}
return 0;

}


#9

#include<stdio.h>
int main()
{
int x;
float y,total;
scanf("%d %f",&x,&y);
if(x%5==0 && x<=y)
{
total=(y-x)-0.50;
printf("%.2f
“,total);
}
else
{
printf(”%.2f
",y);
}
}


#10

why do i get run time error(SIGSEV) for thi code
https://www.codechef.com/viewsolution/8927820


#11

#include <stdio.h>
void main()
{
int x;
float y;
scanf("%d",&x);
scanf("%f",&y);
if(x%5==0)
{
if(x<y)
{
y=y-x;
y=y-0.5;
printf("%.2f",y);

	}
	else
	{	printf("%.2f",y);
	}
															
		}
else
			{
						printf("%.2f",y);
			}

}link text


#12

Why an i getting run-time error in this program even if its running in my Net Beans ?https://www.codechef.com/submit/KOL1502


#13

//Sum of palindromic numbers
#include<stdio.h>
main()
{
int n,r,sum=0,count=0,temp;
printf(“Enter a number:”);
scanf("%d",&n);
temp = n;
while(n>0)
{
r =n%10;
sum = (sum * 10) + r;
n = n/10;
count = count + r;
}
if(sum==temp)
{
printf("%d is a palindrome!
",temp);
printf("The sum is:%d
“,count);
}
else
{
printf(”%d is not a palindrome!
",temp);
}
}

Why i am getting run time error? I am running it on linux platform.


#14

runtime errors occurs when there is any logic error in that program or in any exceptional cases


#15

My code is wprking fine on all ides including ideone and even on codechef compiler but still it is not getting successful submission . Please can somebody help me on this? here is the link to my java code:
https://www.codechef.com/ide


#16

#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int n,m,p,i,j,b;
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;i++)
a*=0;
while(m–)
{ b=1;
scanf("%d",&p);
if(a[p]<=0)
a[p]=0;
for(i=p-1,j=p+1;i>=0||j<=n-1;i–,j++)
{
if(a*<b)
a*=b;
if(a[j]<b)
a[j]=b;
b++;
}

	}
	for(i=0;i<n;i++)
	printf("%d ",a*);
	printf("

");
}
return 0;
}


#17

#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int n,m,p,i,j,b;
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;i++)
a*=0;
while(m–)
{ b=1;
scanf("%d",&p);
if(a[p]<=0)
a[p]=0;
for(i=p-1,j=p+1;i>=0||j<=n-1;i–,j++)
{
if(a*<b)
a*=b;
if(a[j]<b)
a[j]=b;
b++;
}

	}
	for(i=0;i<n;i++)
	printf("%d ",a*);
	printf("

");
}
return 0;
}


#18

include

int main() { int t; scanf("%d",&t); while(t--) { int n,m,p,i,j,b; scanf("%d%d",&n,&m); int a[n]; for(i=0;i=0||j<=n-1;i--,j++) { if(a*<b) a*=b; if(a[j]<b) a[j]=b; b++; }

    }
    for(i=0;i<n;i++)
    printf("%d ",a*);
    printf("
");
}
return 0;

}


#19

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

int main()
{
int n,i,j,k,T,a[n],sum=0;

scanf("%d",&T);
if(T<1 || T>30)
{
exit(0);
}

for(i=1;i<=T;i++)
{

int sum=0;
int sum1=sum;

scanf("%d",&n);
int q=n;

for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
if(a[j]<1 || a[j]>1000000)
{
exit(0);
}
}

for(k=0;k<n;k++)
{
sum=sum+a[k];
}

sum1=sum;

if(sum1%2==0)
{
printf("%d
",n);

}
else
{
for(k=0;k<n;k++)
{
q–;
sum1=sum1-a[k];
if(sum1%2==0)
{
printf("%d
",q);
break;
}
}
}
}

return 0;

}


#20

#include<stdio.h>
void disp( );
void mergesort(int,int,int);
void msortdiv(int,int);
int a[50],n;
void main( )
{
int i;
printf("
Enter the n value:");
scanf("%d",&n);
printf("
Enter elements for an array:");
for(i=0;i<n;i++)
scanf("%d",&a*);
printf("
Before Sorting the elements are:");
disp( );
msortdiv(0,n-1);
printf("
After Sorting the elements are:");
disp( );
return 0;
}
void disp( )
{
int i;
for(i=0;i<n;i++)
printf("%d ",a*);
}

void mergesort(int low,int mid,int high)
{
int t[50],i,j,k;
i=low;
j=mid+1;
k=low;
while((i<=mid) && (j<=high))
{
if(a*>=a[j])
t[k++]=a[j++];
else
t[k++]=a[i++];
}
while(i<=mid)
t[k++]=a[i++];
while(j<=high)
t[k++]=a[j++];
for(i=low;i<=high;i++)
a*=t*;
}
void msortdiv(int low,int high)
{
int mid;
if(low!=high)
{
mid=((low+high)/2);
msortdiv(low,mid);
msortdiv(mid+1,high);

mergesort(low,mid,high);
}
}