istiyak916
BAN USER
- 0of 0 votes
Answerswhat is the output
- istiyak916 in India
main()
{
char x=-1>>2;
printf("%d",x);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersfind the bug in the given source code
- istiyak916 in India
main()
{
char x=300,y;
y=300*300/x;
printf("%d",y);
}| Report Duplicate | Flag | PURGE
- 0of 0 votes
Answerswhat is difference between " return " and " exit ".
- istiyak916 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswap to input any number and double it without using any operator
- istiyak916 in India| Report Duplicate | Flag | PURGE
C
Algo :
1. keep a pointer which always pointing the head node say *root
2. take the value x
3. check if list is empty
if true
allocate new node
insert value x
on the next field put addr of root
return
4. else
take another pointer *p where p=root->next
while p!=root
check each node value with x
if location found
allocate new node
insert node
return
else
p=p->next
use this one
suppose pointer *p is in current position
p=p + ((k * sizeof(struct node) ) - (k * work_size));
Declare an array of number[]={"one","two" ... }; upto 99
and another array of place[]= {"hundred","thousand" ... }; upto your need.
now count the number of digits
e.g while(1){
v=x/10; /* v is any temp variable and x contain your number */
count++; /* initial value = 0 */
if(v==0)
break;
}
on count we get the no. of digits .
Reverse the digit
e.g
temp=v;
num=0;
while(temp!=0){
v=x%10;
num=num*10+v;
x=x/10;
temp--;
}
now on every odd value of v (i.e number of digits ) read two at a time (>3)
suppose : 12345
so here we have 5 digits ,therefor read first two value at a time 12
and do it as
char *ch;
ch=number[12];
printf ch;
if digit==5
ch=place[2]; and so on...
printf ch;
o/p = twelve thousand
and for last three digit read first
ch=number[v];
print ch;
if(v==3)
ch=place[1];
print ch;
/* append the result to o/p */
o/p = twelve thousand three hundred
if(v<3)
ch=number[v];
print ch;
append answer with o/p
o/p = twelve thousand three hundred forty five
to get the mirror of any BAT simply do swap the root->left to root->right
- istiyak916 March 22, 2014use the approach that i have given no message will loss ..
it is very similay to interrupt handling ( isr and bottom halves )
put all critical job in one function and put all the deffered job in another and
schedule deffered function to run later ...
most of the RTOS uses very much similay technique ...
this is an easy approach
1. first take a dynamic buffer .
2. and my timer is capable for handling one request at a time .
3. if suppose multiple request is generated so , what we all need to do is this
4. we take the request put it inside the buffer and make a linked list of it
5. so , we have all the request in my list . now go through the list and clear all the pending job .
6. one thing make sure that whenever a request is genereted immediatly save the status of your current job and handle the request so no request get lost ....
thank u
n=sizeof(int) * CHAR_BIT; /* it is define in limits.h header file which gives no.
of bits in a character on that particular compiler */
int mask = 1 << (n-1);
for(i=0;i<=n;++i){
printf("%c ",((a & mask)==0) ? '0': '1');
a <<= 1;
if(i % CHAR_BIT == 0 && i < n)
putchar(' ');
}
printf("\nfinal value of a = %d\n",a);
use ftell for both array say(m and n) add m+n and div by 2. get the median
- istiyak916 September 01, 2013operation is
printf("%d %d %d\n",++a,a,a++);
in this case what happen
all the post-increament create stack internally
for example
{
int a=3;
printf("%d %d %d\n",a++,a++,a++);
}
first a++ value =3 push on stack and then increament value i,e a=4
2nd a++ value=4 push on stack and then increament value i,e a=5
and also
3rd a++ value=5 push on stack and then increament value i,e a=6
now start popping first pop=5
2nd pop=4 and 3rd pop=3
and the final output is=5 4 3
Now in your case ++a,a,a++
so stack contain only one value =3
pre-increament and simple 'a' value always contain maximum value i,e 5 5
for example
if a=3;
++a,++a,a,++a
ans=6 6 6 6
{ suppose we have 1 2 3 4 and we have to swap 2 with 3 so after swapping ge get 1 3 2 4 .now let we have to struct pointer *p and *q. *p indicating number 2 and *q indicating number 3.
code: }
#pragma pack(1)
typedef struct node
{
int info;
struct node *next;
}node;
void display(node *p)
{
while(p!=0)
{
printf("%d ",p->info);
p=p->next;
}
printf("\n");
}
void swap(node *p)
{
node *q;
q=p->next;
p->next=q->next;
q->next=p->next->next;
p->next->next=q;
printf("after swaping nodes are:\n");
display(p);
}
main()
{
void display(node *);
void swap(node *);
node *p,*q,*r;
int i;
printf("create node:\n");
scanf("%d",&i);
r=(node *)malloc(sizeof(node));
r->info=i;
r->next=0;
p=r;
while(scanf("%d",&i))
{
if(i==0)
break;
q=(node *)malloc(sizeof(node));
q->info=i;
q->next=0;
r->next=q;
r=q;
}
while(1)
{
printf("enter your choice:\n");
printf("1: to display\n");
printf("2: to swap\n");
printf("3: to exit\n");
scanf("%d",&i);
switch(i)
{
case 1: r=p;
display(r);
continue;
case 2: swap(p);
continue;
case 3: exit(0);
}
}
}
when a pointer points to the function and its return type is also a pointer then it is pointer to function . This concept is very useful in datastruct .
- istiyak916 August 14, 2012i think it segmentation fault because pointer is a variable which holds only address so
p contain address another variable * is use to access that variable .
so &p is segmentation fault
node *p,*r,*q;
p=malloc(sizeof(node));
p->x=value;
p->next=null;
r=p;
while(1)
{
q=malloc(sizeof(node));
q->x=value;
q->next=p;
p=q;
}
now it retrieve list with p it follows FIFO form
try this one:
main()
{
short int *p=0,k;
printf("enter no:\n");
scanf("%hd",&k);
printf("%d",&p[k]);
}
inside:
p[a] means *(p+a) and if we take & then we get address means
(p+a);
try this in linux.
without using operator means you are not allow to use any operator either it is bitwise logical or any other
- istiyak916 April 17, 2012
Repdianamowery95, Consultant at Delve Networks
My Name is Diana Mowery. I am from St. Louis and received a Bachelor Degree and My Masters Degree from ...
Repmonicaralvarado94, Korean Air Change Flight at Athena Health
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
int check_paldm(char *str){
- istiyak916 March 29, 2014char *p,*ptr;
ptr=str;
int len;
len=strlen(str);
p=ptr+len-1;
while(*ptr!='\0'){
if(*p>=97)
*p=*p-32;
if(*ptr>=97)
*ptr=*ptr-32;
if(*ptr>91 || *ptr<65){
ptr++;
continue;
}
if(*p>91 || *p<65){
p--;
continue;
}
if(*p==*ptr){
printf("p = %c and ptr = %c\n",*p,*ptr);
p--;
ptr++;
continue;
}else{
return FALSE;
}
}
return TRUE;
}