83 Posted Topics

Member Avatar for Steffi

I don't want to sound rude, but this is a C forum. You should've started this thread in [url=http://www.daniweb.com/forums/forum165.html]Community Introductions[/url]

Member Avatar for cohen
0
22
Member Avatar for vadrag
Member Avatar for devnar
0
99
Member Avatar for SarahYan

It's because of the scope of yearofstart declared inside the struct record lies only within that structure. If you want your program to print 1950, do this: [code=c]struct record{ char *name; char acct_type; struct date yearofstart; }customer={"Jones",'A',1950};[/code] Or do this: [code=c] printf("%s %c %d \n",customer.name,customer.acct_type,yearofstart.year);[/code]

Member Avatar for SarahYan
0
118
Member Avatar for En-Motion

@adrianapatty_28 Start a new thread for your problem. Do this: [QUOTE=Denniz][code]printf("%d occurs %d times\n", i, counters[i]);[/code][/QUOTE] and change your last for loop from [icode]for(i=0;i<num_int;i++)[/icode] to [icode]for(i=0;i<11;i++)[/icode].

Member Avatar for ArkM
0
319
Member Avatar for Andragon

Your showVec function should be: [code=c] void showVec( float v[] ) { int i; for(i=0; i<MAX; ++i) { printf( "%.2f ", v[i] ); } [/code] Your divide function should be: [code=c] void divide() { int i; for(i=0; i<MAX; ++i) { if(v2[i]==0) { printf("Divide by zero error\n"); return; } v3[i] = …

Member Avatar for devnar
0
169
Member Avatar for dampecram
Member Avatar for atman

[code=c]#include<stdio.h> // include header int get_int(void); // Function prototype is to be declared as the function is defined after main() main() // Change to int main() { printf ("Enter an integer:"); get_int(); // Call function. No error as the function was declared previously printf ("Good!\n"); } int get_int(void) { int …

Member Avatar for ajay.krish123
0
120
Member Avatar for PoetGuy

[url]http://richardbowles.tripod.com/cpp/linklist/linklist.htm[/url]. If you need more material, just search the web. There's not shortage for data structures tutorials.

Member Avatar for devnar
0
36
Member Avatar for gayatri.saha

Your question seems clumsily constructed and you haven't used [url=http://www.daniweb.com/forums/thread93280.html]code tags[/url]. Be specific when asking questions.

Member Avatar for WaltP
1
109
Member Avatar for atman

Do you want to do it just so you could justify it to the right? If so you could use this: [code]int i=444; printf("[COLOR="Red"]%9d[/COLOR]",i);[/code] It won't include any zeroes at the beginning but it'll be right justified.

Member Avatar for yuvaraj.tr
0
99
Member Avatar for johnray31

[icode]typedef struct_compare[/icode] is [icode]typedef struct compare[/icode]. I guess it was just a typo. I created a sample structure 'compare' and created two variables of type 'compare'. I initialized the members of one type and assigned it to the other using '=' operator. It seemed to work fine. Did i miss …

Member Avatar for ArkM
0
127
Member Avatar for galmca

So you really believe that the person who posted this problem is still waiting for an answer even after TWO years and wants to look at crappy looking code?

Member Avatar for devnar
0
261
Member Avatar for atman

[code=c] #include <stdio.h> #include <stdlib.h> #include <conio.h> #define MAX 10 int main() { char ch, str[MAX]; int i=0; do { ch=getch(); if(ch>='0'&& ch<='9') { //Code here printf("%c",ch); str[i++] = ch; } else if(ch!='\r') { printf("\nDo not enter alphabet. It'll be ignored\n"); printf("Enter the no again\n"); for(i=0;i<MAX;i++) str[i] = '\0'; i=0; …

Member Avatar for devnar
0
99
Member Avatar for gunjanagrawal

[QUOTE=rohanvijay;726520]im having lot of problems in c and c++ programs...can u please tell me the sites where i ciuld find the solutions of almost all c/c++ programs..[/QUOTE] Solutions to [B]ALMOST ALL[/B] C/C++ programs? That's asking for quite a lot, dontcha think? We don't even have [B]ALMOST ALL[/B] C/C++ problems yet. …

Member Avatar for nucleon
-1
186
Member Avatar for IrishUpstart

[QUOTE=rohanvijay;726523]how to write the C program of pyramid: 1 2 3 4 5 6 7 8 8 10[/QUOTE] Start a new thread for that. Sheesh!

Member Avatar for devnar
0
106
Member Avatar for henks

[QUOTE=ddanbe]I don't know what your problem is, but I appreciate your efforts. Divide your decimal number by 2. Record the remainder(should be 0 or 1) divide again and record again until your decimal number becomes zero. The record of 0 and 1 digits is your binary number. Do the reverse …

Member Avatar for henks
0
145
Member Avatar for sharpst

[url]http://www.daniweb.com/forums/announcement118-2.html[/url] Show us what you've got so far. If you're totally clueless about what you've to do, i'll give you a head start. Here's what the program should do: 1. Promt the user for a choice. (1.addition 2. subtraction 3. multiplication and so on) 2. Read the choice using scanf() …

Member Avatar for ajay.krish123
0
786
Member Avatar for yinfu89

[url=http://www.daniweb.com/forums/thread93280.html]Code tags[/url] Your problem states that you have to [B]read[/B] 20 integers which means that you'll have to use scanf() to get the input from the user. Then you've to display the [B]number[/B] of even and odd numbers present. [code] while(there are still nos to read) //or no of integers …

Member Avatar for ddanbe
0
133
Member Avatar for ahfan_85

In the sorting algorithm, [icode]for(index = 0;index < num;index++)[/icode] should be [icode]for(index = 0;index < num-1;index++)[/icode] That's one extra useless iteration to perform. Also, if num=10, then in your code, when index = 9, next = 10. Then mark[next] (which is mark[10]) will have a garbage value.

Member Avatar for ahfan_85
0
295
Member Avatar for kyeong

What's [icode]departure_time[/icode] and [icode]arrival_time[/icode] doing in the function? You've passed them as arguments in the function, but they aren't being made to point to anything. Better thing to do would be to assign them to the variable pointed to by [icode]best_index[/icode] in both [icode]departure_times[][/icode] and [ICODE]arrival_times[][/ICODE] and do all the …

Member Avatar for devnar
0
150
Member Avatar for msundastud

>>And you cannot declare void function and then expect to get some result from it Is it a bad practice or against the standard? Cause even i use it in functions when I want to pass control back to the main function. I know the convert function in this program …

Member Avatar for devnar
0
164
Member Avatar for kinger29

The problem is to print the obtained remainders in the reverse order which implies that you'll have to store some sort of information abt what remainders you obtained in the previous step. One way to do it is to use a character array as such: [icode]char convert = "01";[/icode] Then …

Member Avatar for devnar
0
182
Member Avatar for MyRedz

1. [url=http://www.daniweb.com/forums/thread93280.html]Code tags[/url] 2. Your program makes no sense. Even your problem statement is a li'l confusing. Do you want to make the user aware of the error when he inputs a number other than 0 or 1 or do you wanna convert every input into 0 or 1 using …

Member Avatar for Aia
0
106
Member Avatar for anny**

Also you are compiling the program as a *.cpp. I think it should be *.c. But it's pretty irrelevant since you don't even have the required header file.

Member Avatar for devnar
0
227
Member Avatar for nishant3316

All warring aside. . . Please be more specific when you post the thread. Your first post barely gives any info on what your problem is and where you are stuck up. >but i don't know the syntax for using it.. If your problem is only finding out the syntax, …

Member Avatar for ahamed101
0
212
Member Avatar for jared_masc

Nobody's gonna go through that code if you don't use code tags. Here's how: [url]http://www.daniweb.com/forums/thread93280.html[/url]

Member Avatar for stilllearning
0
247
Member Avatar for En-Motion

>>Here's another redirection [url]http://cboard.cprogramming.com/showthread.php?t=107852[/url] That's wicked dude!

Member Avatar for ahamed101
0
298
Member Avatar for rrreeefff

[icode]scanf ("%d", &a);[/icode] a is declared as a float, so %d should be %f. Function definition- [icode]int mypower(float a, int n);[/icode] there's no semicolon at the end. (as Salem pointed out.) [icode]int power[/icode] [icode]return 0.0;[/icode] I think power should be declared a float. You might get a warning for that.

Member Avatar for devnar
0
498
Member Avatar for makubexiii

[icode]Insert(nd *head);[/icode] Shouldn't the above be [icode]Insert(nd head);[/icode]? You've already used typedef to make a variable of type 'nd' a pointer to struct node. So when you declare [icode]Insert(nd *head);[/icode], i think head becomes a pointer to a pointer to a structure. Even i'm still learning, so correct me if …

Member Avatar for makubexiii
0
140
Member Avatar for devnar

I found the following code in the 'Code snippets' section( written by nanodano). i tried compiling it in my Dev-Cpp compiler, and i got the output as shown in the attachment for up, left, down and right arrow keys respectively. All other defined keys i.e., F1 to F10 gave the …

Member Avatar for devnar
0
197
Member Avatar for devnar

[CODE=C]#include<stdio.h> #include<conio.h> int main() { float a=0.7; if(a<0.7) printf("C"); else printf("C++"); getch(); return 0; }[/CODE] The above code prints 'C'. Whereas the following two codes prints 'C++'. Why is that? [CODE=C]#include<stdio.h> #include<conio.h> int main() { float a=0.7; if(a>0.7) printf("C"); else printf("C++"); getch(); return 0; }[/CODE] [CODE=C]#include<stdio.h> #include<conio.h> int main() { …

Member Avatar for smart_pc
0
586
Member Avatar for devnar

I have tried to come up with a 2-D (4 rows and 4 columns) array which holds values from 0 to 15, with none of the values used more than once. I'm posting only the code snippet. please lemme know if the logic is correct. [CODE=C] int HIGH=16; /*(Max value …

Member Avatar for devnar
0
110
Member Avatar for lilgrneyes

Even i'm prettty much new to C programming, but i'll try my best to help. One of the errors is the illegal use of 'address of' operator. When you use the "&" in ur printf statements, it'll print the address of the variable and not it's value. And if u …

Member Avatar for devnar
0
97

The End.