govind.chauhan143
BAN USER#include<stdio.h>
int checkpalindrom(char *s,char *s1)
{
while(s<s1)
if(*s++!=*s1--)
return 0;
return 1;
}
void main()
{
char string[30],c;
int i=0,j=0,n=0;
printf("\n Enter the Msg :- ");
gets(string);
printf("\n Palindram substring are as follow \n\n");
for(i=0,j=0;string[i];i++)
{
if(string[i]==' ' || string[i]=='\t')
{ c=*(string+i);
*(string+i)='\0';
if(checkpalindrom(string+j,string+i-1))
printf("\n %d) %s",++n,string+j);
*(string+i)=c;
j=i+1;
}
}
if(checkpalindrom(string+j,string+i-1))
printf("\n %d) %s",++n,string+j);
}
@vogelmanj ...right expln.
- govind.chauhan143 June 30, 2012Compiler errror....explicit call of destructor i.e is s.~A().
- govind.chauhan143 June 29, 2012yup....as we know that fork is used to create the child process
(which p.t to parent next step instruction ) duplicate of parent process plus we can't which process while get first Machine it is depends on CPU .
if progm content 1 fork then there is 2 process.
if progm content 2 fork then there is 4 process.
if progm content 3 fork then there is 8 process.
if progrm content 4 fork then there is 16 process.
growing binary tree....8 time one and 8 time two (2^n where n= number of fork() call ).
- govind.chauhan143 June 29, 2012int a=(char *) ( &variable+1 ) - (char *)( &variable );
variable can be any data type i.e(Basic, Derive, Userdefine(struct,enum) ).
#include<stdio.h>
void main()
{
int N;
int i=0;
int k=2;
int j;
printf("how many prime number to print ?");
scanf("%d",&N);
while(i<N)
{
for(j=2;j<k/2;j++)
if(k%j==0)
break;
if(k%j!=0 || k==j)
{
printf("\t %d",k);
i++;
}
k++;
}
getch();
}
o/p
how many prime number to print ?103
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 101 103 107 109
113 127 131 137 139 149 151 157 163 167
173 179 181 191 193 197 199 211 223 227
229 233 239 241 251 257 263 269 271 277
281 283 293 307 311 313 317 331 337 347
349 353 359 367 373 379 383 389 397 401
409 419 421 431 433 439 443 449 457 461
463 467 479 487 491 499 503 509 521 523
541 547 557 563
int main()
{
float f1,f2;
f1=10.34;
f2=10.34;
if(!(f1-f2))
printf("f1==f2");
else
printf("f1 !=f2");
}
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int n=127;
int count=0;
int i;
clrscr();
for(i=1;n;i=i<<1) // count the number of 1's and make it 0;
if(n&i)
{
count++;
n=n^i;
}
printf("\n number of 1's =%d \n",count);
/* now n value become zero and we have cout the number of 1s bits */
while(count) // add number of one to the right most...
n= n|1<<sizeof(int)*8 - count--;
printf("%u",n);
getch();
}
o/p
number of 1's =7
65024
/* Remark :-- if number is int only then it wil be ans must be negative
*/
Given number is integer like=> 128--->00000000 00000000 00000000 10000000.
- govind.chauhan143 June 24, 2012If it is segmentation fault the allocate the 1d character array of size len which is longest string then copy the string.
- govind.chauhan143 June 24, 2012turbo c
- govind.chauhan143 June 24, 2012#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char *str1="19999999999999999999999999";
char *str2="12999934556677898856565678";
char *str;
int len,lno1,lno2,carry=0;
len=strlen(str1)>strlen(str2)?strlen(str1):strlen(str2);
strlen(str1)>strlen(str2)?strcpy(str,str1):strcpy(str,str2);
lno1=strlen(str1)-1;
lno2=strlen(str2)-1;
while(lno1>=0 && lno2>=0 )
{
str[--len]='0'+((str1[lno1]-48)+(str2[lno2]-48)+carry)%10;
carry=(str1[lno1--]-48+str2[lno2--]-48+carry)/10;
}
while(carry)
{
str[len-1]='0'+(str[len]-48+carry)%10;
carry=(str[len--]-48+carry)/10;
}
printf("\n%s",str);
}
o/p
32999934556677898856565677
Instead of link list simple use ponter , bcoz link list will require extra memory then char *ptr ...ok
- govind.chauhan143 June 24, 2012o/p c) 7
- govind.chauhan143 June 15, 2012o/p
556
hey ur code is write but making number in reverse....
index value must be zero and not need to used strlen function...
for(index=0;name[index]!='\0';index++) okkk
#include<stdio.h>
- govind.chauhan143 July 10, 2012int checkpalindrom(char *s,char *s1)
{
while(s<s1)
if(*s++!=*s1--)
return 0;
return 1;
}
void main()
{
char string[30],c;
int i=0,j=0,n=0;
printf("\n Enter the Msg :- ");
gets(string);
printf("\n Palindram substring are as follow \n\n");
for(i=0,j=0;string[i];i++)
{
if(string[i]==' ' || string[i]=='\t')
{ c=*(string+i);
*(string+i)='\0';
if(checkpalindrom(string+j,string+i-1))
printf("\n %d) %s",++n,string+j);
*(string+i)=c;
j=i+1;
}
}
if(checkpalindrom(string+j,string+i-1))
printf("\n %d) %s",++n,string+j);
}
input and output as follow ....
Enter the Msg :- hi madam and mom gud day
Palindram substring are as follow
1) madam
2) mom