15,551 Topics

Member Avatar for
Member Avatar for dineshswamy

i did a simple bubble sort but it is ot working . help me out. [CODE] #include<stdio.h> main() { int i,j,k; int a[]={7,9,4,2,3,6}; for(i=0;i<7;i++) for(j=i+1;j<7;j++) if(a[j]<a[j-1]) { k=a[j]; a[j]=a[j-1]; a[j-1]=k; } for(i=0;i<7;i++) printf("a[%d]==>%d",i,a[i]); } [/CODE]

Member Avatar for dineshswamy
0
110
Member Avatar for djextazy

As this is my first post on this forum I want to say "Hello!" to everybody and I hope that we'll help each other as much as we can and we'll be very good friends. :) So, this is my problem ( a rather simple one but I don't know …

Member Avatar for hust921
0
208
Member Avatar for sridhar.selva

hi can u ppl help me on this. can i use multiple enums in a single c program, if so is there any constrain on it? [CODE]enum pattern1 {red, green, yellow} pt1; enum pattern2 {orange, blue, black} p2; enum pattern3 {white, grey, violet} p3;[/CODE] is this possible????

Member Avatar for sridhar.selva
0
166
Member Avatar for outout1234

I want my program to just continue as long as the user press any key How do we do it with only use of scanf?? for example: int main(void) { while(1) /*my program goes here*/ printf("Hit any keys to continues......"); scanf // how? }

Member Avatar for Arch Stanton
0
179
Member Avatar for ahspats

i have to write a program, in which i have to make pointer to point to the character, where it last occured in a string. For example: String: Lord of the rings Character: r Pointer points to the last 'r' in the string, that is in the word 'rings'. If …

Member Avatar for yasin.uohyd
0
215
Member Avatar for shaker naser

I want to Write a program that determines the day number (1 to 336) in a year for a date that is provided as input data. As an example, January 1, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996, is day 336, since 1996 is …

Member Avatar for thines01
0
320
Member Avatar for foreshadowed

Greetings all; what I'm trying to do is create an array of structs dynamically by using functions for allocation, display, and then freeing memory. I'm *able* to do the process if it's within scope of the foo declaration, but the initFoo function throws an exception. I *think* it's the order …

Member Avatar for MonsieurPointer
0
150
Member Avatar for yamigx

hi guys .. i have an assignment .. and i didn`t now that i have to do it by tomorrow and now i have no time .. i will be thankful if you can help me.. "Write a program that determines the day number (1 to 336) in a year …

Member Avatar for zeroliken
0
300
Member Avatar for theCompiler

how can i convert this into a struct? the program is prnting all the even nos [CODE]void main() { int num[5],even[5],count,j=0; clrscr(); printf("Enter 5 numbers\n"); for(count=0;count<5;count++) { scanf("%d",&num[count]); } for(count=0;count<5;count++) { if((num[count]%2)==0) { even[j]=num[count]; j++; } } printf("EVEN:\n"); for(count=0;count<j;count++) { printf("%d\t",even[count]); } getch(); }[/CODE]

Member Avatar for zeroliken
0
104
Member Avatar for jdm

I'm working on a tcp server and client for linux. I want the tcp server to send a 10MB file to it on request and I want the client to save it to local disk. I would appreciate any help on it. Thanks for the help. jdm server: [CODE] /* …

Member Avatar for gerard4143
0
262
Member Avatar for sreevisakh2007

[CODE] unsigned int *a; a = (int*)malloc(1*sizeof(int)); a[0] = 10; a[1] = 20; a[100] = 40; printf("%u",a[100]); [/CODE] I have created a pointer named a and allocated 'single' int space for it but still i can store and retrieve more than that. This code runs. Then what is the need …

Member Avatar for Ancient Dragon
0
153
Member Avatar for python_adz

hello everybody, please help me in solving the problem of finding the XOR value of 4 bits as i require it in my project. i tried ^ sign, but it doesnt work for four variables? kindly help

Member Avatar for L7Sqr
0
107
Member Avatar for Massa3332

Hello everyone, I've been having a problem with some of my scanf() functions being skipped after I input a string with a space in between (e.g Jack Daniels). I've been trying to fix it, but it has been driving me crazy. [CODE]#include <stdio.h> #include <stdlib.h> struct Student { int studentNumber; …

Member Avatar for Arch Stanton
0
210
Member Avatar for angelineang

i got no idea how to correct the error,can help me? this is a chem quiz that contain 20 question but i need to random everytime 10 question,other than this,also have a calculator,& mini games [CODE]#include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> #include<windows.h> int main (void) { int option,question,i,count,z=0; char choice,game,quit; int selection; …

Member Avatar for Ab000dy_85
0
291
Member Avatar for Dr_Freeman

Greetings. I'm currently implementing small ANN on my microcontroller. I need to calculate sigmoid activation function. The problem is that I cannot use standard c libraries like math.h so I need custom written pow function. This is how it will be used:pow(e,-(someFloat)); Did anyone have already implemented something similar ?

Member Avatar for histrungalot
0
624
Member Avatar for Ribamar23

hi when i try to use atof i get different values every time i run my app code: [CODE]#include <stdio.h> #include <string.h> #include <math.h> int main(int argc, char **argv){ char* a = "100"; double b = atof(a); printf("%f", b); }[/CODE] why do i get different results everytime i run my …

Member Avatar for WaltP
0
87
Member Avatar for johnnydarten

Dear all, I'm a C beginner and I was doing a small practice nested loop on C when I got a very strange error which when the console opens tells me that my program has stopped working. here is the code: [CODE] #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> …

Member Avatar for johnnydarten
0
172
Member Avatar for DarkMonarch

is it possible in C to do an unfix size array like in Java ? if so, howto ? thx guys Dark

Member Avatar for DarkMonarch
0
195
Member Avatar for Kycas

Hi, I want to filter .BMP image with 3x3 digit matrix. Basicly it is multiplying image pixels by numbers in matrix. Any suggestions how it should be done? I know that i have to open a file using fopen() I did that. Should I just loop through whole image and …

Member Avatar for Kycas
0
78
Member Avatar for coding101

im writing a chat server in c and am need help. my server can write to a socket, the client can read from the socket. How do i have the client write to the socket and have the server read from the client socket? server.c [CODE] #include <stdio.h> #include <unistd.h> …

Member Avatar for histrungalot
0
217
Member Avatar for newbie14

Dear All, I have a function with input parameter as const u_char *p. So when I write like this printf("\n\n Char value p : %.2x",(unsigned int)p[1]). It gives me a hex value. How to print the whole p value which method is best to use. I need to analyse it …

Member Avatar for newbie14
0
474
Member Avatar for karoma

Hi guys, I'm trying to develop a card program, which seems to be working fine, with the exception of the dealing part. The deck is initialised, shuffled, then is supposed to deal out 5 cards without duplicates. However I keep seeing duplicates when I deal. I've ran though it countless …

Member Avatar for WaltP
0
131
Member Avatar for benclifford

Hi, I have a task to perform which all to do with the smurfs, reading from a file and doing some simple stuff to it. The last part I need to do is print out a list of all smurfs and their corresponding role in alphabetical order. I am hoping …

0
245
Member Avatar for megaman656

for example, i want to combine two number 6 and 8 and it will equal 68. is this possible in C? [ICODE]int a = 6, b = 8,c; c=ab; [/ICODE] and c will = 68.

Member Avatar for VernonDozier
0
107
Member Avatar for arnamoy10

Hello; For the below program, I am trying to create a procnanny program which will monitor the processes according to the specification said in a configuration file. The parent process will create fork() child processes each for monitoring a process as specified in the configuration file. The configuration file is …

Member Avatar for arnamoy10
0
174
Member Avatar for linezero

[CODE]void merge() { if(start==NULL) { start=start2; } else { temp=start; while(temp->next!=NULL) { temp=temp->next; } temp->next=start2; } temp=start; if(start==NULL) printf("\nList is empty"); else { printf("\nElements of the list:\n"); while(temp!=NULL) { printf("%d\t",temp->info); temp=temp->next; } } system("pause"); system("cls"); main(); }[/CODE] the following code is use to merge two linked list into one and …

Member Avatar for thines01
0
185
Member Avatar for myk45

Hello. i was trying to solve this problem: [B]You’re given an array containing both positive and negative integers and required to find the subarray with the largest sum (O(N)). Write a routine in C for the above. [/B] i was able to find the largest sum. However,i had little trouble …

Member Avatar for VIKAS REDDY
0
726
Member Avatar for patthar

My application is testing devices connectivity using ping (ICMP) functionality. It is working fine for all devices but for a particular device that is CISCO wireless controller it is not able to ping the device. I am able to ping the device through command prompt but when i debug my …

0
49
Member Avatar for jodzjcm

I have this code: Note: boom.ok[1][0] has the character "a" while boom.ok[[tempr[0]][0] contains the string "ay". [CODE]if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 1) printf("Hello"); if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 0) printf("Hello");[/CODE] None of these statement prints hello. Why?

Member Avatar for Ab000dy_85
0
94
Member Avatar for varul7

C program to replace all the letters of a string with all 26 alphabets and to do permutations to all the substituted ones and finally store the resulted strings in a file.. please help me out in fixing this situation.. To be clear. let me quote an example: If i …

Member Avatar for varul7
0
935
Member Avatar for mustafasadikot

i m having trouble with updating the fie. every time the code is executed, the variables are not retrieved from the file and start from the scratch. moreover, the file is not updated. plz reply

Member Avatar for WaltP
0
134
Member Avatar for Xheis

Hi, so I have this assignment to create a scheduling algorithm, I tried looking everywhere for help on how to create one and the closest one was here, where I found a great source code, yet I tried to modify it with my assignment variables and I created some nasty …

Member Avatar for histrungalot
0
3K
Member Avatar for ineedsomehelp:3

[CODE]void alternate(char wordWord[][MAX],char wordVar[],int word[],int i,int j, int k, int l) { char ang[4],si[3],ni[3],ay[3],sa[3],kay[4]; int X,Y,Z1,Z2; strcpy(ang,"ang"); strcpy(si,"si"); strcpy(ni,"ni"); strcpy(ay,"ay"); strcpy(sa,"sa"); strcpy(kay,"kay"); tokenize(wordWord,wordVar,word,i,j,k,l); if(wordWord[j][k] == ang[4] || wordWord[j][k] == si[3]) X = wordWord[j][k]; else if(wordWord[j][k] == ni[3]) Z1 = wordWord[j][k]; else if(wordWord[j][k] == ay[3]) Y= wordWord[j][k]; else if(wordWord[j][k] == sa[3] …

Member Avatar for ineedsomehelp:3
0
332
Member Avatar for sridhar.selva

[CODE]#include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> int main() { int fd; int wd=0; unsigned char buff[] = { 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x01, 0x21, 0x03}; fd = open("/dev/ttyS0", O_RDONLY | O_NOCTTY | O_NDELAY ); if (fd == -1) …

Member Avatar for Ab000dy_85
0
264
Member Avatar for rushikesh jadha

why this code not produce any reaction on any command [CODE]#include<stdio.h> #include<unistd.h> #include<fcntl.h> #include<stdlib.h> void count(char c,char *fn) { int lc=0,wc=0,cc=0,handle; char ch; if(handle=open(fn,O_RDONLY)==-1) { printf("File %s fail to open",fn); return; } while(read(handle,&ch,1)!=0) { if(ch==' '||ch=='\n') { wc++; }else cc++; } if(ch=='\n') { lc++; } close(handle); switch(c) { case 'c': …

Member Avatar for thekashyap
0
157
Member Avatar for arold10

I want to write this function integerPower(base, exponent) that return the value of base^[I]exponent[/I] For instance integerPower(3, 4) = 3*3*3*3 The function has two parameters my question is how can I use the for loop to control the calculation? It's not that hard to use the for loop when the …

Member Avatar for arold10
0
316
Member Avatar for Silver-Eye

So I'm fairly sure I have everything in the correct order, it compiles correctly, but when I try to run I just crash after the first Employee ID input. I've tried all i can think and have searched the web yet can't figure out why it crashes. [CODE] #include <stdio.h> …

Member Avatar for zeroliken
0
165
Member Avatar for varunrathi

i am working on a program to find the factorial of a number of any length. i have used an integer array to store the digits of the result. the problem is that i am unable to store more than 32000 digits in the array. if i give a larger …

Member Avatar for gerard4143
0
1K
Member Avatar for hwoarang69

in test function the for loop work fine but printf(num[0])is getting 0. does any one know why? [CODE] int main(void) { char num[20]; num[0] = '3'; num[1] = 'a'; void test(num); } void test(char num[]) { for(a = 0; a < 20; a++) { printf("%c",num); } printf("%c",num[0]); } [/CODE]

Member Avatar for rubberman
0
84
Member Avatar for hwoarang69

does any one know why my for loop work fine but printf("%c",num[0]); get me 0? [CODE] void test(char[]); void test2(char[]); int main(void) { char num[10]; test(num); test2(num); } void test() { num[0] = '1'; num[1] = '2' } void test2(int num[]) { for(a = 0; a < 10; a++) { …

Member Avatar for rubberman
0
138
Member Avatar for CKShia

What is meaning of "nature of entity"? e.g. kind of function, global variable? Is there any code to check it? Also, how to detect the memory section in memory map? e.g. environment, command line arguments, code/, global initialized data, global uninitialized data, stack, heap etc. Is there any code to …

Member Avatar for Ancient Dragon
0
203
Member Avatar for sridhar.selva

serial port problem is occuring,,, pls guide on the same as i new to this,,, [CODE]#include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> int main() { int fd; int wd=0; unsigned char buff[] = { 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x01, …

Member Avatar for sridhar.selva
0
416
Member Avatar for sharathg.satya

hi all can i know how to find greatest of two numbers? the condition is we should not use any comparision operators.. thanks in advance

Member Avatar for sharathg.satya
0
125
Member Avatar for kahheng93

Hi,im making a console application,i would like certain printf:("") to have different colour than the others,is that possible?

Member Avatar for kahheng93
0
70
Member Avatar for rithish

[CODE]#include <stdio.h> #include <stdlib.h> int main () { int i,n,big; int * pData; printf ("Amount of numbers to be entered: "); scanf ("%d",&i); pData = (int*) calloc (i,sizeof(int)); if (pData==NULL) exit (1); for (n=0;n<i;n++) { printf ("Enter number #%d: ",n); scanf ("%d",&pData[n]); } big=pdata[0]; for(n=0;n<i;n++) { if(big>pdata[n]) { big=pdata[n]; } …

Member Avatar for deceptikon
0
127
Member Avatar for rithish

what is the use of malloc,calloc,realloc ?? i studied i didnt get proper knowledge .why instead of this why cant we use array???

Member Avatar for deceptikon
0
122
Member Avatar for MrAppleseed

I'm currently working on a dictionary library in C and would like to start using struct's for easy assignment. Now, I have several functions that need to be a member in said struct's. I have it working well using pointers, but my only problem is that I would like to …

Member Avatar for L7Sqr
0
112
Member Avatar for irre

hi there im wondering about the difference between: int nr; if(!((nr--)%5)){...} if(!((nr--)%5)){...} and: int nr; if(!(--nr)%5)){...} if(!(--nr)%5)){...} is it right that in case 1 nr will be decremented after true/false comparison and in case 2 in advance? assuming nr=123456; in case 1 it would be true for second if.... and …

Member Avatar for WaltP
0
153
Member Avatar for rithish

[CODE]#include<stdio.h> struct rec { int i; float PI; char A; }; int main() { struct rec *ptr_one; ptr_one =(struct rec *) malloc (sizeof(struct rec)); ptr_one->i = 10; ptr_one->PI = 3.14; ptr_one->A = 'a'; printf("First value: %d\n", ptr_one->i); printf("Second value: %f\n", ptr_one->PI); printf("Third value: %c\n", ptr_one->A); free(ptr_one); return 0; } [/CODE] …

Member Avatar for deceptikon
0
116
Member Avatar for kahheng93

hi guys,i was trying to make user able to make selection again when they make an invalid input, but when i run this code,it just doesnt work that way,it goes printing the same line like crazy...did i do something wrong? [CODE] int main (void) { //Local Declarations int menu; //Statements …

Member Avatar for kahheng93
0
149

The End.