Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Complete IIT AIEEE ICSE ISC PMT help forum

Complete help forum for students preparing for icse iit aieee cbse pmt and other related exams.Stay updated about all 2011 exams.
 
HomeHome  PortalPortal  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  India NewsIndia News  
Keywords
2010 CLASS computer 2007 physics ICSE 2006 graph YEAR science 2009 SELECT paper 2004 prelim CASE papers question RESULT UNION
Latest topics
» Nitration of aniline - IIT JEE 2018 Advanced - solved
Whats Wrong ?? EmptyFri Jun 08, 2018 2:34 am by adianadiadi

» Diamagnetic - Paramagnetic - Ni(CO)4, [Ni(CN)4]2- and [NiCl4
Whats Wrong ?? EmptyFri Apr 06, 2018 1:05 am by adianadiadi

» IIT JEE chemistry solved interactive question paper
Whats Wrong ?? EmptySun Oct 29, 2017 12:11 pm by adianadiadi

» IIT JEE 2015 SOLVED QUESTION PAPER
Whats Wrong ?? EmptyWed Oct 19, 2016 1:44 pm by adianadiadi

» IIT JEE chemistry solved questions
Whats Wrong ?? EmptySat Jul 18, 2015 6:15 pm by adianadiadi

» General Description of Chinese Market for Foaming Agent ADC
Whats Wrong ?? EmptyFri May 09, 2014 2:09 pm by happybaicaitou

» How to get Lowest Cost MBBS Admission?
Whats Wrong ?? EmptyMon Feb 24, 2014 6:39 pm by MENTOR 2014

»  girl boy vashikaran specialist agori baba ji +91-9461165
Whats Wrong ?? EmptyTue Jan 21, 2014 6:00 pm by krshastri

»  STRONG LOST LOVE SPELL +91-9461165176
Whats Wrong ?? EmptyTue Jan 21, 2014 6:00 pm by krshastri

Top posters
abhas
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
Anu..i luv icse...:)
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
G-7
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
siya
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
Candy
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
jOhNy
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
Apurva
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
WinRrule
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
ambili
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 
saif
Whats Wrong ?? Vote_lcapWhats Wrong ?? Voting_barWhats Wrong ?? Vote_rcap 



Search if you can't find it here

Whats Wrong ??

View previous topic View next topic Go down
AuthorMessage
RC
Active member
Active member
RC


Whats Wrong ?? Vide
PostSubject: Whats Wrong ?? Whats Wrong ?? EmptyWed Mar 17, 2010 6:58 pm

Pls tell me whats wrong with this prog..this is not working..
this is the soln to 1st prob of Sec B in Specimen Paper 2010

import java.io.*;
class Prime
{
int arr[][],r,c;
Prime()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please Enter Number Of Rows : ");
r=Integer.parseInt(br.readLine());
System.out.println("Please Enter Number Of Columns : ");
c=Integer.parseInt(br.readLine());
}
int isPrime(int p)
{
for(int i=2;i<=p/2;i++)
if(p%i==0)
return 0;
return 1;
}
void fill()
{
int i,j,x=1,pos=1;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
for(x=pos;;x++)
if(isPrime(x)==1)
{
pos=x;
arr[i][j]=x;
}
System.out.println("a");
}
void display()
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
System.out.println(arr[i][j]+" ");
System.out.println();
}
}
void main()throws IOException //if error is not thrown here,exception occurs.
{
Prime obj=new Prime(); //Object named obj is created.
obj.fill();
obj.display();
}
}
Back to top Go down
WinRrule
Active member
Active member
WinRrule


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyWed Mar 17, 2010 7:36 pm

i am also struck in the same program..! Whats Wrong ?? Icon_sad
Back to top Go down
RC
Active member
Active member
RC


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyWed Mar 17, 2010 7:52 pm

i just cant figure out why my prog is'nt working,, Sad
Back to top Go down
saif
Active member
Active member



Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyWed Mar 17, 2010 8:31 pm

Done have removed 5-6 bugs from your prog..

Here is the correct version

Test output
Please Enter Number Of Rows :
5
Please Enter Number Of Columns :
5
2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
53 59 61 67 71
73 79 83 89 97
//program

import java.io.*;
class mainp
{
public static void main(String args[])throws IOException //if error is not thrown here,exception occurs.
{
Prime obj=new Prime(); //Object named obj is created.
obj.fill();
obj.display();
}
}

class Prime
{
int arr[][],r,c;
Prime()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please Enter Number Of Rows : ");
r=Integer.parseInt(br.readLine());
System.out.println("Please Enter Number Of Columns : ");
c=Integer.parseInt(br.readLine());
arr=new int[r][c];
}
int isPrime(int p)
{
for(int i=2;i<=p/2;i++)
if(p%i==0)
return 0;
return 1;
}
void fill()
{
int i,j,x=2;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
while(isPrime(x)!=1)
{x++;}
arr[i][j]=x;
x++;
}
}
}
void display()
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{System.out.print(arr[i][j]+" ");}
System.out.println();
}
}
}
Back to top Go down
saif
Active member
Active member



Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyWed Mar 17, 2010 8:31 pm

ALL IZZZZ WELLLLL
Back to top Go down
kevinjo911




Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 11:55 am

hey dude put the main method in the beginning else it wont work....... Whats Wrong ?? Icon_wink
Back to top Go down
RC
Active member
Active member
RC


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 11:58 am

thanks saif..
but are we allowed to make another class not mentioned in the question ??
Back to top Go down
saif
Active member
Active member



Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 2:29 pm

@RC

thats exactly the question that I have planed to ask my comp teacher before exam.Unfortunately i don't have his mobile number or else i would have asked him by now
Back to top Go down
WinRrule
Active member
Active member
WinRrule


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 4:23 pm

U don't need another class..!
Back to top Go down
G-7
Active member
Active member
G-7


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 5:08 pm

no no no no..winrule..! can we just use any other class as an extra..? will there be any penalty for it.?
Back to top Go down
RC
Active member
Active member
RC


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 5:34 pm

i know winrule we dont need it..just asking if its allowed..else it can be done this way--
import java.io.*;
public class Prime
{
int arr[][],r,c;
Prime()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please Enter Number Of Rows : ");
r=Integer.parseInt(br.readLine());
System.out.println("Please Enter Number Of Columns : ");
c=Integer.parseInt(br.readLine());
arr=new int[r][c];
}
public int isPrime(int p)
{
for(int i=2;i<=p/2;i++)
if(p%i==0)
return 0;
return 1;
}
public void fill()
{
int i,j,x=2;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
while(isPrime(x)!=1)
{x++;}
arr[i][j]=x;
x++;
}
}
public void display()
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
System.out.printf("%2d ",arr[i][j]);
System.out.println();
}
}
public static void main(String args[])throws IOException //if error is not thrown here,exception occurs.
{
Prime obj=new Prime(); //Object named obj is created.
obj.fill();
obj.display();
}
}
Back to top Go down
WinRrule
Active member
Active member
WinRrule


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 6:38 pm

yes RC.. that's what is expected..

@G-7, when they r not asking for it to be called from another class y do extra and give the examiner chance to cut marks?
Back to top Go down
RC
Active member
Active member
RC


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 7:19 pm

ok thanks
Back to top Go down
WinRrule
Active member
Active member
WinRrule


Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? EmptyThu Mar 18, 2010 7:27 pm

Welcome..!
Back to top Go down
Sponsored content




Whats Wrong ?? Vide
PostSubject: Re: Whats Wrong ?? Whats Wrong ?? Empty

Back to top Go down

Whats Wrong ??

View previous topic View next topic Back to top
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Complete IIT AIEEE ICSE ISC PMT help forum :: ISC :: ISC 2010 [Class xii] :: Computer-