15,552 Topics

Member Avatar for
Member Avatar for saurabh.mehta.33234

The following piece of code outputs 0.1000000000001 float a=0.1; printf("%lf",a); But if I add a 10 times as long float b=0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1; printf("lf",b); It outputs as 0.999999999999989 But if a=0.1 is stored as 0.1000000000001 then the answer should be greater than 10 due to the 1 in last column.Then why is …

Member Avatar for deceptikon
0
241
Member Avatar for somename

Hello. I am trying to find out how to write a function to replace a string in a text file. So far i got this: find -> is a word i am looking for replace, rep -> new word, f1 -> my file. And i'm stuck with that piece of …

Member Avatar for deceptikon
0
3K
Member Avatar for saurabh.mehta.33234

Why this piece of code doesnot display array contents #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = {23,34,12,17,204,99,16}; int main() { int d; for(d=-1;d <= (TOTAL_ELEMENTS-2);d++) printf("%d\n",array[d+1]); return 0; }

Member Avatar for deceptikon
0
127
Member Avatar for blindislands

So my teacher gave us this file #include <stdio.h> #define MAXVALS 100 /* max number of values we can process */ int tableFill(double a[], int max); void tablePrint(double a[], int num); double tableAverage(double a[], int num); int tableMatchingElements(double a[], int num, double target); int main() { double table[MAXVALS]; /* array …

Member Avatar for nullptr
0
133
Member Avatar for gelaisg18

Hi guys can you please help me with this. All I need to do is input a number and display the corresponding alphabet.For example 2 then the output should be A B.. I am working on a code but my problem is the output is displaying together with a special …

Member Avatar for gelaisg18
0
511
Member Avatar for sunfizu
Member Avatar for chandnigandhi

I am making a text editor in c language and have been stucked with code of go to line number,selecting a text,copying a text,cut text and pasting a text... so please any one can help me out of this as soon as possible....i have submissions by 1st december....

Member Avatar for Schol-R-LEA
0
90
Member Avatar for coolerking

im trying to make my own Serialization library but I have some problems with the following. I have a package wich I serialize to a t_stream and then I need to serialize the t_stream to a char * again. This is the complete code: typedef struct{ int16_t port; int16_t priority; …

Member Avatar for deceptikon
0
158
Member Avatar for needhelpalways

#include<stdio.h> #define ROW 5 #define COL 5 int main(){ int array[ROW][COL]; int r=0, c=0; for (r=0; r<ROW; r++){ for (c=0; c<COL; c++) array[c][r] = (c+1)-(r+1); } for (r=0; r<ROW; r++){ for (c=0; c<COL; c++) printf("%5d", array[c][r]); printf("\n"); } printf("\n\n"); system("pause"); return 0; } i need help in this code I …

Member Avatar for Nutster
0
294
Member Avatar for collin_ola

Hi, I seem to be having a problem with my code below, which I would like to be able to use to return 2 values from the result of a quadratic equation operation. The eReturn function takes care of negative square root values. I'm not getting any errors back, just …

Member Avatar for Miorfs
0
3K
Member Avatar for kidpro

i want to print myname mynam myna myn my m i have done in numbers but i can't print in string/char my code is i want to print myname mynam myna myn my m i have done in numbers but i can't print in string/char my code is main() { …

Member Avatar for Miorfs
0
158
Member Avatar for saurabh.mehta.33234

Does the following code make p as a null pointer static int *p; since `printf("%u",p);` outputs as 0 though the syntax is `int *p=NULL or int *p=0`

Member Avatar for deceptikon
0
155
Member Avatar for rajilakshmi

Find the number of sequences in an integer array. A sequence is a list of numbers that comes in strict numerical order like [3, 4, 5, 6]. Sample Input : [1, 2, 3, 6, 8, 10, 11, 15, 16, 17] Sample Output : 3 sequences Any one can hlp please? …

Member Avatar for Adak
0
164
Member Avatar for noahjonesnoah

Hi all, Im trying to write a program that minimizes a Transition Graph (its basically combining states with similar numbers). Basically, the algorithm is to first find states with the same 'a' and 'b' inputs, combine them, remove them from the 'leftovers' list, then find states that have either 'a' …

Member Avatar for Adak
0
135
Member Avatar for chandnigandhi

I am making a text editor in c language.I need a help for moving characters left,right,up and down.I am using turbo c compiler and i want code for navigation and not an ascii key codes.... please help me with this as soon as possible....

Member Avatar for deceptikon
0
148
Member Avatar for miracle Kimuli

pleas help me Write an algorithm to add and multiply two large integers, which cannot be represented by built-in types.

Member Avatar for Adak
0
169
Member Avatar for ashrafbd

hello i was trying to do one of my assignments but i got stuck at sorting my strut arrays elements by alphabetical order. here is the code that i have dose so far but after this even reading as much as i can, i can not get to go any …

Member Avatar for Adak
0
134
Member Avatar for JohnMcPherson

I am trying read CSV files in a C program on an AIX system. I am having problems getting fscanf to recognize the comma delimeter. I have read previous posts on this issue, and used the techniques dicussed in those threads, but I am still having the issue. Specifically, this …

Member Avatar for JohnMcPherson
0
6K
Member Avatar for celina1234

I have two files which goes like this : FILE A is : J5 J15 J25 J30 J35 and FILE B is: J0 23 56 J5 24 58 J10 26 60 J15 29 63 J20 31 36 J25 23 32 J30 51 14 J35 34 21 J40 46 12 The …

Member Avatar for Ancient Dragon
0
182
Member Avatar for myk45

Hello All, I have a small doubt w.r.t using mutex locks. Say we have a thread-safe function: int counter; void foo() { LOCK_MUTEX(); // say by pthread_mutex_lock ++counter; UNLOCK_MUTEX(); } Now, i understand that this is thread safe because only one thread can "own" a mutex at a time and …

Member Avatar for myk45
0
185
Member Avatar for chipbu

Hi guys, This is not related to syntax or runtime problem. What I am going ask is more about how Linux and Windows handle writing data from buffer to a file. I have this code here, wrapped around a timing block, to write a buffer to a file. StartCounter(); if(rows …

Member Avatar for Adak
0
277
Member Avatar for Stpdoug

Having a small a problem with an array value here is the code:i want the array(totalwin) to store the value of the calulation each time it repeats say 10 times.I tried using the for loop but the values are not stored in the array what am i doing wrong. // …

Member Avatar for Stpdoug
0
188
Member Avatar for kostaskol

Hello there people. I am pretty new in C and programming in general. I was trying to make a password checking programme and I seem to be stuck. int main (void) {char ch; while ((ch=getchar()) != EOF){ This is the beginning of my code and whenever I try to type …

Member Avatar for kostaskol
0
120
Member Avatar for starkk

#include<stdio.h> int myatoi(const char *string); int main(int argc, char* argv[]) { printf("\n%d\n", myatoi("1998")); getch(); return(0); } int myatoi(const char* string) { int value = 0; if (string) { while (*string && (*string <= '9' && *string >= '0')) { value = (value * 10) + (*string - '0'); string++; } …

Member Avatar for nullptr
0
105
Member Avatar for priyambada1

Given an array A of n integers, give an eficient algorithm to check whether there are two numbers in A whose sum is zero. [

Member Avatar for Symbiatch
0
69
Member Avatar for gandalf22

Alright so im supposed to represent an airline. total # of seats is 10. Passangers can choose whether to sit in first or economy. This is what i have so far. If you try the program and try to go from first to economy you will see that it skips …

Member Avatar for zeroliken
0
174
Member Avatar for some one

[CODE]#include <conio.h> #include <graphics.h> #include <stdlib.h> #include <stdio.h> void main (int) { int gdriver=DETECT,gmode,errorcode; //Requesting auto-detection. int midx,midy,x; //Initializing graphics and local variables. initgraph(&gdriver,&gmode,"d:\\bc3\\bgi"); //Reading result of initialization. errorcode=graphresult(); if(errorcode!=grOk) //An error occurred. { printf("Graphics error occurred : %s \n",grapherrormsg(errorcode)); printf("Press any key to stop : "); getch(); exit(1); //Terminate …

Member Avatar for kadawe
0
844
Member Avatar for saddam777

Write a code snippet to declare and accept an integer and calculate the cube value of the integer. The integer should be passed by reference to a function cube(). The function would calculate the result of cubing the integer. The function prototype to be used is: void cube (int *p); …

Member Avatar for <M/>
0
146
Member Avatar for saddam777

1) The & symbol in C returns the address of a variable. 2) In the expression, `printf(ā€œ%dā€, (ans > val)? z : w);` displays the value of w if the condition is true. 3) In the expression, `for( ; a>b; )` A semicolon on its own indicates a null statement. …

Member Avatar for Ancient Dragon
0
137
Member Avatar for saddam777

Write a code snippet to declare and accept an integer and calculate the cube value of the integer. The integer should be passed by reference to a function cube(). The function would calculate the result of cubing the integer. The function prototype to be used is: void cube (int *p); …

Member Avatar for Stpdoug
0
54

The End.