No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
10 Posted Topics
I made the following functions for deleting a node of a singly linked list. 1. Can these functions be improved furthur? 2. Is it necessary to free the memory of the node that is deleted? nodep deleteByValue(nodep p, int value) { nodep temp = p; if(temp->data == value) return temp->next; … | |
Program: #include <iostream> using namespace std; class Rectangle { float len; float bre; public: Rectangle() {cout << "Rectangle constructed!" << endl; len=0; bre=0;} ~Rectangle() {cout << "Rectangle destructed!" << endl;} void setL(float L) {len=L;} void setB(float B) {bre=B;} friend float area(Rectangle rect); }; float area(Rectangle rect) { return rect.len*rect.bre; } … | |
[code=c] #include <iostream> #include <sstream> using namespace std; int main(void) { string str; int i; cout << "Enter an integer: "; getline(cin, str); while(true) { stringstream ss(str); if (ss >> i) { break; } else { cout << "\nPlease enter a valid number: "; getline(cin, str); } } cout << … | |
C++ course has started in my college. I would like to know the best beginner book for C++. My teacher has referred Robert Lafore and The Complete Reference. Since there are a lot of suggestions given in the sticky thread, I am confused. Thanks in advance :) | |
[code=c] #include <stdio.h> int main (void) { float a; a = 7/3; printf ("%f\n", a); } [/code] Result : 2.000000 Why is gcc compiler printing 0 after decimal? | |
I was trying to print the location of array elements using the following code [code=c] #include<stdio.h> main() { int arr[]={10,20,30,40,50,60}; int i; for (i=0; i<6; i++) printf("%d ", &arr[i]); return 0; } [/code] Error: [B]printArrayLocation.c:7:3: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’[/B] While i … | |
The following code is given in my Data Structure reference book. [code=c] #include<stdio.h> main() { int i, *pi; float f, *pf; pi = (int *) malloc(sizeof(int)); pf = (float *) malloc(sizeof(float)); *pi = 1024; *pf = 3.14; printf("an integer = %d, a float = %f", *pi, *pf); free(pi); free(pf); } … | |
This code is not running. i'm using gcc [code=c] #include<stdio.h> int main() { struct book { char name[10]; float price; int pages; }; struct book b[5]; int i; for (i=0; i<5; i++) { printf("Enter name, price and pages\n"); scanf("%c %f %d", &b[i].name, &b[i].price, &b[i].pages); } for (i=0; i<5; i++) printf("%c … | |
Hi I installed Visual C++ 2010 express today. There is no option to create a .C file. I tried googling but found nothing. Please help me with this |
The End.