15,552 Topics
| |
[CODE]#include<stdio.h> #include<string.h> #define SIZE 100 int main(void) { int array[SIZE], i, n, j, sum=0; printf("Enter some integers:"); for (n=0;n<100;++n) { scanf("%d", &array[n]); if(array[n] == -1) { j=n; break; } j=100; } for(j<=100;i>j;++i){ printf("%d", array[n]); } for(j=0;j<n;++j){ sum=sum+array[n]; printf("The sum is %d\n", sum); } return (0); }[/CODE] [I]Im trying to output … | |
Hello....i am trying to send a file from server to the client using socket programming in C, how do i do this?? basically the client is trying to download a file from the server.... | |
Does someone know how to integrate a collection of programs as one whole program? Thanks. :) | |
Here is a complete and working code that 1. Adds the numbers(input) to get a sum(output) 2. Sorts the numbers in a descending order Can you post any suggestions on how I can improve my code :) main.c [CODE]#include <stdio.h> #include "header.h" main (){ int sum, x, y, z,choices; input(&x, … | |
I'm having troubles with the following code [CODE]#include <stdio.h> #include <ctype.h> int main (void) { int i=0,j=0,row; char str1[5], str2[5]; char machine[4][5]={0}; FILE *fp; fp = fopen("text.txt","r"); while (fscanf(fp,"%s %s",&str1,&str2) == 2 ) { row = str1[1]; while (str2[i] != NULL) { machine[row][i]=str2[i]; i++; } } for (i=0;i<5;i++) for (j=0;j<5;j++) … | |
i need to insert a character on a string . for example input is : cafe the output should be caxzfe . i insert xz . i just know how to concatenate two strings but when inserting a character in a string im totally lost . | |
Hi. I have trouble with getting the following program to convert string to float type. What i need to do is this: 12.345e3 = 12345 12e-2=0.12 -12.34=-12.34 -12.34e3=-12340 -12.34e-2=-0.1234 e: = x 10^ I got it to do the basics. However, It doesn't work in case of negative numbers or … | |
Please help me fix my code.. It works in CodeBlocks but when I try in Linux, it says it has an error - SEGMENTATION FAULT (core dumped) :( This program converts between bases of a number. After it converts a number it should go back to start to get input … | |
Hi, in the below given program the answer is 1. agpur 2. jabalpur 3. jabalpur I understood the processing for the first two printf statements but for the last printf statement I could not understand the processing. Could anyone please explain. Thanks in advance :) [code=c]#include<stdio.h> #include<conio.h> void main() { … | |
Here is a program I found [URL="http://www.cs.bgu.ac.il/~omri/Humor/ObfsC.html"]here[/URL] [code] #include <stdio.h> main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_, main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13? main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t, "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\ ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \ q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \ ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \ iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \ ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \ }'+}##(!!/") :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);} [/code] Since I … | |
Can please someone give and explain the algorithm and logic of checking if a given tree is a complete binary tree. Fields available for a node are left and right child and info. Thanks. | |
Hello I've been wondering how to get past the whole "program crashes when user inputs the wrong data type". After extensive amount of google searches I found out that you could use !() as an argument in a loop(or if statement) to avoid that. However by doing that I encountered … | |
The program should change a sentence to pig Latin. [B]Rules[B][/B][/B] A word starting with a vowel should start with a capital letter and the rest with small letters and end with "way". If a word starts with a consonant the first letter will move to the last until it starts … | |
Hi, I have really lame problem which is probably that easy, that I can't get it working. I have program like this below. And I need to make prototype to get it working. But I don't know how it need to look like. I don't want to have these functions … | |
Hello to all. I have a problem with replacing a part of a string with another string. The following code does not work. However, if you remove void in front of replace_str, in Code Blocks i am able to run it (WHY???) despite the fact that i still get a … | |
[URL="http://graphingvariousfunctions.wordpress.com/2011/11/18/how-to-solve-linear-equations-in-10th-grade/"]Solving linear equations[/URL]? It says I have to solve -3k + 4 = 8k - 15 - 6k - 11 On the problem, do I combine like terms on one side first? Like the 8k and the 6k? If so do I add them or subtract them? Can someone please … | |
Hi, I have a problem with c files. I have broken my code to 2 files main.c and unp.h unp.h [CODE] typedef void (*Ptr_To_Function)(void); struct Menu_Record { unsigned int option_number; const char * text; Ptr_To_Function process_function; }; struct Menu_Record* select(struct Menu_Record*,int); struct Menu_Record startup[] = { {1, "Choice1", NULL}, {2, … | |
I'm really confused as to how to set up this program. The program is to have a function "trap", so I'm guessing that means I have to include a function that solves the integral before my main function? [CODE] #include <stdio.h> #include <math.h> double f(double x) { return exp(-x*x); } … | |
[quote]Yes you can. But going from a useful, good coding practice that makes further development easy to hardcoded, poor coding practice that makes further development hard does not sound like a good idea. Any reason why you would recommend such a move?[/quote] It's because sometimes you do exactly what the … | |
Hi, I am trying to make an image viewer, this is my first time developing a software and I was just wondering how to add properties in my application. I'm creating this software with the help of Gtk and C and now I'm stuck because I want to display the … | |
Hallo! I got the following Decimal IP: "3232235876" it represents "192.168.1.100" I got it in the following way: Code: [CODE] //GET IP if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR) { printf("%s","host not found"); } struct hostent *phe = gethostbyname(hostname); memcpy(&addr, phe->h_addr_list[0], sizeof(struct in_addr)); //Convert IP to Decimal notation sprintf(decResult,"%u", addr); sprintf(decResult,"%u", htonl(atoi(decResult)));[/CODE] … | |
Hi all I'm wondering if some one could help me with something as i think i've just forgotten everything i knew :) I have this code: [CODE] #include <stdio.h> #include <stdlib.h> int main() { char A[4]; char B[2]; char C[2]; printf("Enter Numbers: "); scanf("%s",&A); fflush(stdin); printf("Enter Numbers: "); scanf("%s",&B); fflush(stdin); … | |
does somone knows how to creatye a program that well accept five members and display the lowest number | |
Hey, everyone~ Being the second time posting here, I'll try to make it simple but clearly as possible :) So, my assignment this time is about writing a C program to print the following star patterns: [CODE] * * * * * * * * * *[/CODE] So, here is … | |
can an1 plz :)help me to write a program to reverse the individual words present in a string ?? exampe:- my name is raju ym eman si ujar | |
Hi everyone! This is my first post and i'm also a newbie so don't be harsh on me! I have this exercise to do which asks pretty much what the title says. I have a function that reads strings from a file and puts them in an array. Then I … | |
i have made a program with this algorithm but its not working properly my code is given below can you help me to remove the errors [CODE] #include<stdio.h> #include<conio.h> void main() { FILE *f; char ch; int nalpha=0,nword=0,nno=0,nsc=0; f=fopen("abc.txt","r"); if(f!='NULL') { while(ch=getch(f)!=EOF) { printf("%c",ch); if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) nalpha++; else if((ch==' ')||(ch=='.')) nword++; … | |
Hey I'm currently writing a program which takes a file of data sorts it (using bubble sort) and for some reason I keep getting a segmentation fault. [CODE] #include <stdio.h> #include <stdlib.h> void compare(int numberstocheck[], int n) { int i, j, k; int thebucket[n]; for(i = 0; i < n; … | |
[CODE]#include<stdio.h> int main() { int a,b,c; (printf("\nEnter 2 no.s"))?(scanf("%d%d",&a,&b))?(c=(a>b)?a:b):0:0; while(c>=1) {if(a%c==0 && b%c==0) {printf("\nGCD:%d",c);return 0;} c--; } }[/CODE] | |
i have written a code on assembler... when we enter the mnemonics it will give opcode... when i use %x in the printf it is giving correct opcode.. but when i use %c or %s it is printing some different characters.. but what i want is if i use %s … |
The End.