83 Posted Topics
Re: [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 … | |
Re: 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? | |
Re: [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; … | |
Re: [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. … | |
Re: [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! | |
Re: [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 … | |
Re: [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() … | |
Re: [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 … | |
Re: 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. | |
![]() | Re: 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 … |
Re: >>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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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, … | |
Re: 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] | |
Re: >>Here's another redirection [url]http://cboard.cprogramming.com/showthread.php?t=107852[/url] That's wicked dude! | |
Re: [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. | |
Re: [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 … | |
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 … | |
[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() { … | |
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 … | |
Re: 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 … |