## Profile

Nitish Mittal
Attends Dhirubhai Ambani Institute of Information and Communication Technology
Lives in gandhinagar
177 have him in circles

## Stream

### Nitish Mittal

Shared publicly  -
1

### Nitish Mittal

How-To/Tutorials  -

Hello Everyone!!!
I need a help, I want to find the probability of a word occurring given one or two previous words in a sentence. For example if sentence is " The color of rose is red" then what is the probability of occurring red given is and rose.
Any kind of link of Api or research articles would be helpful﻿
1

### Nitish Mittal

Code/Snippets  -

import java.io.IOException;

public class Solution {

public static void main(String[] args) throws IOException {

int k = getInt();
String s = getString();

int n=0,m=1;
int l = s.length();
int no = (l*(l+1))/2;
String[] sub = new String[no];
int i =0;
while(n<=l && i<no)
{
if(m==l+1){
n++;
m=n+1;
}

sub[i] = s.substring(n,m);

i++;
m++;
}
int total = 0;
System.out.println(sub.length);
for(int j=0;j<sub.length-1;j++)
{
for(int z=j+1;z<sub.length;z++)
total = total + mismatch(sub[j],sub[z],k);
}
System.out.println(total);

}
public static int mismatch(String s1, String s2,int k)
{
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
int i=0;
int n=0;
int b = c1.length;
int c = c2.length;
while(i<b && b==c){
if(c1[i]!=c2[i])
n++;

i++;
}
// System.out.println(s1 + " " + s2 +" "+n);
// System.out.println(k);
if(n<=k && b==c){
return 1;
}
else
return 0;
}

public static String getString() throws IOException{
return s;
}

public static int getInt() throws IOException{
String s = getString();
return Integer.parseInt(s);
}
}

in the line " int l = s.length();" i am getting NULLPOINTEREXCEPTION error can anyone suggest what wrong is there??﻿
1

### Nitish Mittal

Anything  -

#include<stdio.h>
#include<conio.h>

int main(){
void (*p)();
int (*q)();
int (*r)();
p = clrscr;
q = getch;
r = puts;
(*p)();
(*r)(" C Programming");
(*q)();
return 0;
}

what would be the output of this program?﻿
2

I was curious to see how char read_write[] = "C Programming" is typically compiled, so I had a look: http://pastebin.com/raw.php?i=UU8N6xDZ﻿

### Nitish Mittal

Anything  -

int main()
{
char str[2];
char v[3];
fgets(str,3,stdin);
printf("\n");
fgets(v,4,stdin);
printf("%s\n%s",str,v);

return 0;
}
why am I not getting the desired result?
On pressing enter the the program terminates and stores only one string.
how to take two string input from stdin one after the other??﻿
1

Thank You all for your suggestions!!! It helped me a lot :)﻿

### Nitish Mittal

Anything  -

Are the three declarations char **apple, char *apple[], and char apple[][] same?
how are the different??﻿
2

Oh Yeah you are right. Thanks for the clarification. (apple[][]  isn't actually a valid type)
And yes as  mentioned array pointers are constant and can't be incremented. ﻿
In his circles
210 people
Have him in circles
177 people

### Nitish Mittal

Shared publicly  -

ISWC 2013 is the premier international forum for the Semantic Web / Linked Data Community. Here, scientists, industry specialists, and practitioners meet to discuss the future of practical, scalable, user-friendly, and game changing solutions.  #iswc2013 #semanticweb #datascience  ﻿
1

### Nitish Mittal

Shared publicly  -

1

### Nitish Mittal

Anything  -

void main()
{
clrscr();
if(sizeof(!6.0))
printf("%d",sizeof(6.0,2));
else
printf("i don't know");
getch();
}
the output is 4 can someone explain me this code?﻿
2
1

I was always talking about the result of the if statement that's why I've always use "1 (true)" and used "if (sizeof(something))". Of course the sizeof(x) could be something different than one, just as I've pointed on my first comment.﻿

### Nitish Mittal

Anything  -

j = (char*)&a;

what does above statement mean?﻿
1

If you're referring to  's code snippet, that's not what it does. His code is perfectly legal; the only casting that's done is from "pointer to int" to "pointer to char", so no information is lost there.

It's only when you dereference j that things get interesting: depending on your platform endian, *j = 43 or 0.

(And to be clear, this only applies to  's code.  's snippet is simply too incomplete to draw any conclusions, especially since we don't know what types a and j are.)﻿
People
In his circles
210 people
Have him in circles
177 people
Places
Currently
gandhinagar