Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
100% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
0 Endorsements
~5K People Reached
Favorite Forums
Favorite Tags
c x 36
c++ x 19
null x 1
Member Avatar for gaurav_13191

Hi all, I have a minor confusion regarding the variable accessed Consider: [CODE] int a=5; //global variable void increment(int a) { ++a; } [/CODE] If I call increment() in main(), which a will be incremented (a passed as a parameter to the function or the global a ?) Also specify …

Member Avatar for gaurav_13191
0
76
Member Avatar for gaurav_13191

Hi, the following is the code for returning the position of a substring within a string(Brute force algorithm) [CODE] //Brute Force Algorithm #include<stdio.h> #include<string.h> int main(void) { char s1[20],s2[10]; int x1,x2,j,k,i; printf("Enter string 1:"); gets(s1); printf("Enter string 2:"); gets(s2); x1=strlen(s1); x2=strlen(s2); if(x1<x2) return 0; for(i=0;i<=x1-x2;i++) { j=i; k=0; while((s1[j]==s2[k])&&k<x2) { …

Member Avatar for koberoc
0
150
Member Avatar for gaurav_13191

I am trying to find out inorder successor of a node in a binary search tree. I read the algorithm from "Introduction to Algorithms,Cormen" and understood it. But the problem I face is that I can't find out the parent of the node when it is needed in the algorithm. …

Member Avatar for thekashyap
0
424
Member Avatar for gaurav_13191

Hi all, I am trying to code iterative implementation of bst. But I am encountering some problems as the stack is not updated as it should be. I am getting incorrect output.Some suggestions would be welcomed. [CODE] /*Operations to be performed:- ->Insertion ->Deletion ->Modification ->Search ->Minimum ->Maximum ->Predecessor ->Successor ->Inorder …

Member Avatar for gaurav_13191
0
181
Member Avatar for gaurav_13191

Hi all, I have a doubt regarding finding a loop in a linked list.I searched on internet and found 2 different ways of doing the same. But my doubt is that if a linked list has a loop, then wouldn't it be a circular linked list? If yes, then the …

Member Avatar for gaurav_13191
0
88
Member Avatar for gaurav_13191

Hello all, I am third year student pursuing computer science engineering and I want to develop a software which can be coded in C and includes integrating it with database for data. I really need help for some ideas which are new(I need to develop something which is original or …

Member Avatar for pseudorandom21
0
144
Member Avatar for gaurav_13191

I have the following code for converting a list of t infix expressions into their postfix form:- [CODE] #include<stdio.h> #include<string.h> #include<ctype.h> #define MAX 400 struct stack { char arr[MAX]; int top; }; void initstack(struct stack *); void push(struct stack *,char); char pop(struct stack *); void convert(struct stack *s,char *); int …

0
77
Member Avatar for gaurav_13191

I have the following code for Quick Sort procedure: [CODE] #include<stdio.h> void Quick_sort(int *arr,int left,int right); int Partition(int *arr,int left,int right,int pivotindex); int main() { int a[20],n,ctr=0,j=0; printf("\nEnter number of elements:"); scanf("%d",&n); printf("Enter array elements:"); while(ctr<n) { scanf("%d ",&a[ctr]); ctr++; } Quick_sort(a,0,n-1); printf("\nSorted Array:"); while(j<n) { printf("%d ",a[j]); j++; } …

Member Avatar for vinitmittal2008
0
146
Member Avatar for gaurav_13191

Consider the error in following program- [CODE] #include<stdio.h> #include<conio.h> #define MAX 100 struct stacktype { int stack[MAX]; int top; } ; void push(struct stacktype * s,int item) { if(s->top==MAX-1) { printf("Overflow"); return; } s->top++; s->stack[s->top]=item; } int pop(struct stacktype *s) { int item; if(s->top==-1) { printf("UnderFlow"); return -1; } item=s->stack[s->top]; …

Member Avatar for gaurav_13191
0
166
Member Avatar for moye88

I'm trying to get the maximum temperature and the day it occur from the value I put in. But the Max is always the last value i put in and the day is always 8 :( Can anyone see what is wrong with the code? Thanks in advance. #include<stdio.h> int …

Member Avatar for moye88
0
151
Member Avatar for gaurav_13191

I have written the following code for converting infix to prefix.. [CODE] //Infix to prefix conversion #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> #define MAX 25 void initstack(struct stack *); void push(struct stack *,char); char pop(struct stack *); char *convert(struct stack *,char *); void show(struct stack); int priority(char); struct stack { char arr[MAX]; …

Member Avatar for Schol-R-LEA
0
232
Member Avatar for gaurav_13191

This is my code for drawing a circle using mid point algorithm:- [CODE] //Midpoint circle algorithm #include<graphics.h> #include<stdio.h> #include<conio.h> void drawcircle(int xc,int yc,int r); int main() { int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"..//bgi"); drawcircle(250,250,10); getch(); return 0; } void drawcircle(int xc,int yc,int r) { int p,x=0,y=r,incr1=2*x+3,incr2=incr1+2-2*y; void drawPixel(int,int,int,int); drawPixel(xc,yc,x,y); p=1-r; while(x<=y) { if(p<0) …

Member Avatar for Adak
0
120
Member Avatar for gaurav_13191

I have the following code for DDA Line Algorithm in C :- [CODE] //DDA Line Algorithm #include<stdio.h> #include<graphics.h> #include<conio.h> #include<math.h> #include<stdlib.h> #define Round(a) ((int)(a+0.5)) void linDDA(int xa,int ya,int xb,int yb); int main() { int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"E:\\TC\\bgi"); linDDA(10,20,200,100); clrscr(); getch(); return 0; } void linDDA(int xa,int ya,int xb,int yb) { int …

Member Avatar for gaurav_13191
0
105
Member Avatar for gaurav_13191

I have the following function to delete nodes in a doubly linked list at a specified position [CODE]void Delete(struct dnode **ptr,int pos) /*pos refers to position at which element is to be deleted and ptr is the pointer to the first node in the list */ { struct dnode *temp; …

Member Avatar for prvnkmr194
0
1K
Member Avatar for Rahul.menon

I Wanted some good patterns questions that is challenging. Also some logic teasing questions. forums like codechef have questions bit too absurd to understand. It would be really good if someone could provide questions easy to understand yet logically challenging.

Member Avatar for gaurav_13191
0
92
Member Avatar for gaurav_13191

Hi, I have the code to add elements at the end of the linked list using recursion. [CODE] //Adds an element at end using recursion #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node { int data; struct node *link; }; void addatend(struct node **,int); void display(struct node *); int main() { struct node …

Member Avatar for N1GHTS
0
557
Member Avatar for gaurav_13191

Hi, I want to know which function can be used for inputting a number of lines in C?

Member Avatar for Narue
0
61
Member Avatar for gaurav_13191

I found the following code on internet for adding two numbers using pointers:- [CODE] #include<stdio.h> int main() { int a=30000,b=20,sum; char *p; p=(char *)a; sum= (int)&p[b]; printf("%d",sum); return 0; } [/CODE] But I can't understand how p holds the value 30000 or how the result of the program is addition …

Member Avatar for Narue
0
188
Member Avatar for gaurav_13191

Hi coders,I have a small problem regarding pointers, I am a bit weak in pointers and need to understand why the following is wrong: [CODE] int main(void) { char *a; gets(a); return 0; } [/CODE] This causes an exception, please explain the error. I am using Turbo C as compiler, …

Member Avatar for gaurav_13191
0
104
Member Avatar for gaurav_13191

Hi, I have the following code which compiles absolutely fine.. [CODE] using namespace std; #include<iostream> #include<stdio.h> #include<conio.h> struct node { int data; struct node *link; }; void add(struct node **,int); void display(struct node*); int count(struct node *); int main(void) { struct node *p; p=NULL; add(&p,5); add(&p,1); add(&p,6); add(&p,4); add(&p,7); display(p); …

Member Avatar for arkoenig
0
99
Member Avatar for gaurav_13191

Hi, I have the following code which compiles fine but does not produce any output.. [CODE] using namespace std; #include<iostream> #include<cstdio> #include<conio.h> struct node { int data; struct node *link; }; void append(struct node *,int); void addatbeg(struct node *,int); void addafter(struct node *,int,int); void display(struct node *); int count(struct node …

Member Avatar for gaurav_13191
0
94
Member Avatar for gaurav_13191

I have a problem in which we are given 2 sets A and B and we have to find set C which contains elements common to A and B.The set A and B can contain duplicates and set C is expected to contain distinct elements(i.e no repetition of the same …

Member Avatar for Rashakil Fol
0
131
Member Avatar for gaurav_13191

I have the following code to find first and second largest elements of an array: [CODE] using namespace std; #include<iostream> #include<conio.h> #include<cstdio> #include<string.h> int* create(int); int maximum(int *,int); int second_max(int *,int); void freememory(int*); int main(void) { int *p,size; cout<<"Enter size of the array:"; cin>>size; p=create(size); cout<<"\nMaximum elemnt in the array …

Member Avatar for gaurav_13191
0
99
Member Avatar for gaurav_13191

Hi.. I am new to Dani web and would like to know the problem in the following code: [CODE] #include<iostream.h> #include<conio.h> void insertion_sort(int *p); int main() { int a[20],j; cout<<"\nEnter contents of array:"; for(int k=0;k<20;k++) { cin>>a[k]; } insertion_sort(a); return 0; } void insertion_sort(int *p) { int h,key; for(int i=2;i<20;i++) …

Member Avatar for gaurav_13191
0
89
Member Avatar for gaurav_13191

Hi,I am new to daniweb and would like to know the error in this code [CODE] void initpoly(struct poly *p) { int i; p->noofterms=0; for(i=0;i<MAX;i++) { p->t[i].coeff=0; p->t[i].exp=0; } }[/CODE] I am not posting the entire program because it is lengthy.I am getting the error"Expected primary expression before token ;" …

Member Avatar for gaurav_13191
0
240