15,551 Topics
| |
#include <stdio.h> #include<conio.h> #include<alloc.h> struct data { int value; struct data *next; }; int main() { int s; struct data *m,*i; printf("enter the data: "); scanf("%d",&s); i=(struct data *)malloc(size of(struct data); i->value=s; i->next=m; m=i; printf("enter the 2nd data: "); scanf("%d",&s); i=(struct data *)malloc(size of (struct data); i->value=s; i->next=m; m=i; printf("\n … | |
Im trying to implement a program that will check the descriptions of two FA and check if they are equivalent. Im assuming (for simplicity) that each FA is in minimal form, the input alphabet is {a b} and each FA only has one finish state. Format for an FA is … | |
I'm working with some old code and the users tell me that the original program's output was a single binary file containing multiple stuct data. The output I get is a binary file containing a single structure. The comment also indicates that this what is happening but I need to … | |
hey, i want to do a question in which i am given n line segments and i want to find the number of intersection of them. Can anyone tell me the most efficient way i can do it ? I have got some links on google and also from books … | |
SOLENN AND HER SUITORS Solenn has many suitors. To pick a partner, she has the following criteria: her partner's height and weight must be close to hers. Her suitors also want to know how many suitors ranked ahead of them (maybe they want to "get rid" of the other suitors?). … | |
I want to write a program that does the following: reads and integer matrix from stdin and outputs the input matrix, its transpose and multiplication of the input matrix with its transpose. I limited the matrix to a 10x10. I want to ask the user to enter a number of … | |
I was trying to understand how BITWISE OR works in C, and while looking on the web I found an explanation on msdn http://msdn.microsoft.com/en-us/library/17zwb64t.aspx But there I found this short i = 0xAB00; And I really don't know what this code does. I saw it for the first time and … | |
#include <stdio.h> #include <stdlib.h> int main() { int i,n,a=0,b=0,sum=0; printf("enter the limit of amstrong number: "); scanf("%d",n); for(i=1;i<=n;i++) { a=i; while(a>0) { b=n%10; sum=sum+ b*b*b; a=a/10; } if(sum==i) { printf("%d",sum); } } return 0; } it prints no errors but doest not work properly | |
i was watching [this video](http://www.youtube.com/watch?v=jTSvthW34GU&list=EC9D558D49CA734A02&index=2&feature=plpp_video) about type conversion and what the compiler does while converting from small byte formats to large byte formats(and vice versa) etc etc, and tried to write a code for it... but seems that function calls in my code are getting completely bypassed... once again, here … | |
When we define a variable name using #define in macro like: #define BUFFER_SIZE buff 5, and then in our main function declare a variable which has the same name like: int buff=8, Does the second buff overwrite the first one? I mean generally is a macro definition considered related to … | |
#include <stdio.h> #include <stdlib.h> int main() { int a=0,b=1,c=1,d=0,e=0,x,n; printf("enter the limit: "); scanf("%d",&n); while(d<=n) { d=a+b+c; a=b; b=c; c=d; e=a+b+c; for(x=d+1;x<d;x++) { if(x<=n) { printf("the non tribonacci series is: "); printf("\n %d",x); } } } return 0; } actually how to do this it doesnot print the values | |
Hi guys I been programming in c++ for past 2 years and is fairly good with it. First of all I dont need the code or anything but need some resources which i can use to get the basic idea so I can start developing. Had been googling for the … | |
#include<stdio.h> #include<math.h> void getColorCode(char colorCode[]); long getResistorValue(char colorCode[]); int i,ch; long r_value=0; char ans; char j; char code; char colorCode[3]; int colorValue[3]; int main (void) { /* clrscr(); printf("\n\t\t\t\tRESISTANCE CALCULATOR"); printf("\n\t\t\t\t"); for(i=1;i<11;i++) { delay(10000); printf("*"); }*/ printf("\n1. START"); printf("\n2. QUIT"); printf("\nEnter your Choice(1-2):"); scanf("%d",&ch); clrscr(); switch(ch) { case 1: printf("*****************************************************\n\n"); … | |
http://www.spoj.pl/problems/FP/ here is the link. Can anyone please give me the hint only that how greedy approach is following in this question ? It's strange to see how greedy is there in this question. just the hint of this. no code, nothing! thanks. | |
I am making this two player simple game. I just need to make each of the player press a key any time not alternating from one another. Do I still use getch() for a solution? I have tried but the user still presses his/her assigned keys after the other presses … | |
hi everyone well I'm learning network programming currently , I've written a day time client and server but when I run the client it gives me a connection error . Here is my client code #include<sys/socket.h> #include<sys/types.h> #include<stdio.h> #include<netinet/in.h> #include<netdb.h> int main(int argc ,char *argv[]) { int sockfd, n; char … | |
Following is my code for reading from a file. #include<stdio.h> int main() { char s[10][10]; int i=0,j=0; FILE *ptr=fopen("input.txt","r"); char c; while(fscanf(ptr,"%c",&c)!=EOF) { if(c=='\n') { s[i][j]=0; i++; j=0; } else { s[i][j]=c; j++; } } s[i][j]=0; fclose(ptr); for(j=0;j<i;j++) printf("%s\n",s[j]); return 1; } and content of input.txt is A->XAZ|Yz|z X->xZ|x Z->Xz … | |
If a child process encounters exit(0) statement, where is this exit status returned in the parent process? Is there any variable associated with every process that holds this information? If not, how do children and parent processes communicate? | |
#include<stdio.h> #define MOD 100000009 #define REP(i, n) for(i = 0; i < n; ++i) void mul(int a[2][2],int b[2][2]) { int i,j,k; int c[2][2]; for(i=0;i<2;i++) { for(j=0;j<2;j++) { c[i][j]=0; for(k=0;k<2;k++) { c[i][j]+=(a[i][k]*b[k][j]); } } } // matrix multiply i=0;j=0; REP(i,2) REP(j,2) b[i][j]=c[i][j]; // copying the value in back to b[][] return; … | |
where is union required? please explain with an example where having union is a better choice than any data structure. | |
i am writing this code for a school poject it gives mee segmentation fault .please help it scans iput of the form #include<stdio.h> #include<stdlib.h> struct time{ int hh,mm; }; struct date{ int day,month,year; }; struct student{ char firstname[20]; char lastname[20]; struct time entry; struct time leavetime; struct date dt; int … | |
# code to convert any base input to any base output (base limited upto hexadecimal) # ## scanf() works , but gets() stops working from 2nd iteration ## *i apolozise beforehand for the length of this post, i hope there will be someone who'll bear with me :(* **here is … | |
#include<stdio.h> int main() { char a[60][60],b[60][60],i=0,n1,m1,n2,m2; int x,y; int j=0; char c; int p=-1,q=-1,f=-1,g=-1; scanf("%d%d",&n1,&m1); for(i=1;i<=n1;i++) scanf(" %s",a[i]); scanf("%d%d",&n2,&m2); for(i=1;i<=n2;i++) scanf(" %s",b[i]); for(i=1;i<=n1;i++) { for(j=1;j<=m1;j++) { if(a[i][j]=='1') { p=i; q=j; break; } } if(p>0 || q>0) break; } for(i=1;i<=n2;i++) { for(j=1;j<=m2;j++) { if(b[i][j]=='1') { f=i; g=j; break; } } if(g!=-1 … | |
The program is this : Write a program which takes 10 integer numbers from user. Save all the positive numbers to one file, all the negative numbersto another file. So,the coding will be compare all integers with 0 and save according in two different files right? If I am right … | |
I'm trying to compile a program where i am using the libraries studio.h, math.h and conio.h when I try to use the gcc comand it says that conio.h " not such file or directory" | |
this is a code from the book "the C programming language" by dennis ritchie, but for some reason its not working! #include <stdio.h> #define IN 1 /* inside a word */ #define OUT 0 /* outside a word */ /* count lines, words, and characters in input */ main() { … | |
#include<stdio.h> #include<conio.h> main() { int a[5],priority[5],adj[5][5]={0},i,j,k; a[0]=3; a[1]=4; a[2]=5; a[3]=7; a[4]=10; adj[0][1]=1; adj[0][2]=1; adj[0][3]=1; adj[1][0]=1; adj[2][0]=1; adj[2][4]=1; adj[3][0]=1; adj[4][2]=1; /* the ads[4][4] represents the linking edges adj[4][4]= 0 1 1 1 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 … |
The End.