15,552 Topics
| |
Write a program to compute the aritmetic mean (average), median, and mode for up to 50 test scores. The data are contained in a text file. The program will also print a histogram of the scores. The program should start with a function to read the data file and fill … | |
i have a thorough knowledge C and a little bit of practice of C but i wanted to be a good C programer can anybody tell me how i can do it are ther any good books which can provide me good practice of C | |
[U]see the following code-[/U] [code] #include<stdio.h> #include<conio.h> struct emp { int age; char name[6]; }*e; void main() { printf("%u\n",&(e->age)); printf("%u\n",(&(e->age)+0)); printf("%u\n",(&(e->age)+1)); printf("%u\n",(&(e->age)+2)); printf("%u\n\n\n",(&(e->age)+3)); printf("%u\n",(&(e->name)+0)); printf("%u\n",(&(e->name)+1)); printf("%u\n",(&(e->name)+2)); printf("%u\n",(&(e->name)+3)); printf("%u\n",(&(e->name)+4)); printf("%u\n",(&(e->name)+5)); printf("%u\n\n\n",(&(e->name)+6)); printf("%u\n",((e->name)+0)); printf("%u\n",((e->name)+1)); printf("%u\n",((e->name)+2)); printf("%u\n",((e->name)+3)); printf("%u\n",((e->name)+4)); printf("%u\n",((e->name)+5)); printf("%u\n\n\n",((e->name)+6)); } [/code] OUTPUT------------------------------- 0 0 4 8 12 4 10 16 22 28 … | |
Hi, everyone and first off thank you for this great community! So, here is my question about my code: [CODE] #include <pthread.h> #include <stdio.h> int data; // global variable void *thread_function1(void *arg) { int temp,i,j; printf("I'm threadf1\n"); for (i=1;i<=20;i++) { data++; temp=data; temp+=3; j=0; while ( (j++)<1000000 ); data=temp; } … | |
Hi, I'm trying to read data from a text file and store it into an array. I know this issue has been dealt with earlier, but none of those threads seem to be helpful in this case. Sorry in advance if I missed a relevant post. The data in the … | |
hello guys... my problem is that i cannot seem to save the value of ptr pointer.... every time i reference it the value seems to reset. after the initializatin it should have 2w's and 2b's in it.. but when i try and print it. it comes as empty... the entry … | |
Hello., I'm reading about anonymus structs and have problems understanding what is the privilege to have one. could anyone demonstrate an example of both anonymus and regular struct. I see that anonymus struct has a name after the the } and before semicolon. Any help would be greatly appreciated. Thank … | |
Hi all, I working in VC++. I have a void pointer. I am assigning a memory block to it using malloc(). void* buf_ptr = NULL; buf_ptr = malloc(1428480); I am filling this buffer using fread(). and I want to index this buffer (buf_ptr) to acces its data. How can I … | |
I had 1 exercise: read data form file then add into TREE. I read data in the file into an array, then add array into TREE, here is my solution but it does not work properly I know that data in array seq[] will be erased after ReadFile() function but … | |
Hello i m reading chapter in K&R about bit operation whish totally confuses me i understand what all operators does but i dont understand the code itself [code] unsigned getbits(unsigned x, int p, int n) { return (x >> (p+1-n)) & ~(~0 << n); } [/code] it will right shift … | |
Hello, I'm trying to read dictionary words from a file and store the output in a struct element of type unsigned char *. I keep getting a bunch of memory related errors and segmentation faults which Im sure are totally related to me trying to access something that's not really … | |
i dunno im sure this output the good result i dont understand why it got not the output that i want [code] #include <stdio.h> void Squeeze2(char *str,char *save) { int i,x; int buffer=0;//used to save stuff for( i=0 , x=0 ; str[i]!=0 && save[x]!=0 ; i++, x++ ) { if( … | |
hey there, i need some help in understanding pointers. this is an example from school but i cant quite figure i out. i know the basis of pointers but could someone give me some more info. [CODE] #include <stdio.h> #include <string.h> int string_len(char *s); int main() { char s[80]; strcpy(s,"Hello"); … | |
i m trying to code htoi function in chapter 2.3 for K&R but problem i dunno where to start should i first read all string then after that change each character to its decimal and then add them ? or any better ideas? | |
[code=c] #include<iostream> using namespace std; int fact (int num); int main () { cout<<"Enter a number"<<endl; int number; cin>>number; cout<<"Displaying number: "<<number<<endl; cout<<"Calculating Factorial for the number"<<endl; int fact; fact = fact(number); return 0; } int fact (int num) { if(num==1) { return num; } else { return num * … | |
"I am a boy\r\n" if this string is readed through using fgets in an array what will get readed | |
I have an array of integer of size 20 and there values range from 0-9 and i want atleast the value 0 placed in one location in the array once. how can i control rand() to be able to do that? cause there a possibility 1/10 will randomily generate 0 … | |
Hello., Have a question about array being set from function argument. I wrote this little program, and want to know why cant i set an array size from the function argument. Any help would be greatly appreciated. [CODE] int money(int deposit, ...){ int i, sum = 0, nextvar; // myArr[deposit]; … | |
write a program to find size of a file without traversing it character by character? will anybody tell me the logic hw to approach it is there any trick involved | |
| |
I am writing a simple program for managing the final grades of students. The program first read original data from a file called "final.txt", and create a linked list to store the imfornation in memory. The format of the orginal data is "Class_Character Seat_number Computer_grades Laboratory_grades". There is only data … | |
Hello Everybody, I am working on a project and i want to compose one main string out of several substrings in C. for example: I have 3 variables: Float Vx=1,66 Float Vy=1.55 Float Vz=2.3 My first step is to convert them to character arrays usin snprintf. Then i want to … | |
This may be be a silly question, but its baffling me. If I set up a receive interrupt, process the data and clear the flag. All works well. The problem is I need to use printf. I realize that this will of course also generate an interrupt, I handle this … | |
Hi All, I am trying to read a file line by line. If a line contains the following character ':' then that line will be parsed word by word and put in a list. I am trying to do that but the head pointer is changed when we go to … | |
| Below is my prime generator, it works fine only thing it gives me 1 more prime than i want eg., if num=40, i need primes uptill 40 but it gives me 41 also...i want it to stop at 37. It works fine with 90. sample run ======== Enter the number:40 … |
| |
Hello friends, i have some doubt and hope i will get an satisfactory answer from here. 1) Can memory addresses be negative........i have initialized an array and check the address of element and found it negative...so i want to know can it be negative and if yes then how addresses … | |
Hi I've been think about this for a while but the answer eludes me. I know its a pretty simple program but here's the snippet: [code] int main(void){ printf("Enter the operation of your choice\n"); int a; int b; int ch; while((ch = getChoice()) != 'q'){ printf("enter a value: "); if(scanf("%d", … | |
the first time my program runs it gets the character from the keyboard the second time it gets a 10 and I have not pressed any keys on the keyboard [code=c] #include <stdio.h> #include <stdlib.h> void showone(); void showtwo(); void showthree(); void showfour(); void showfive(); void showsix(); int randx(); char … | |
Hi... I've been trying to make a program where the input is txt file, and the output will be saved in txt file. But, I keep getting error Message. My code looks like this: [code] #include <stdlib.h> #include <stdio.h> int main (){ int i,j; float H [100][100]; FILE*in; in=fopen("0.txt","rt"); FILE*out; … |
The End.