Home Discussion 24422-Ask-C Discuss: Ask C/C++ Questions online

  • c/c++kumarbhanuuday May 29, 2011 at 6:55 AM

    write a program in c/c++ to compute control ratios used in budgeting

  • c++ questionsana June 8, 2011 at 10:45 AM

    hi.how can i solve this with c++? a program that compose a class for students,in this class we get the name & id of 300 students.it can add or delete students.it can search students.the student added must be replace with deleted one.

  • c programmingtanusree June 16, 2011 at 9:57 PM

    can ny1 plzz suggest some typical and standard C problems (any type) whch generally are given tech fest coding problems.... i hope u can ndrstand wat types of coding ques i actually want... plzz help...

  • program in c++vicky kanade July 8, 2011 at 7:15 AM

    i have a program merging of two arrays with employee structure(employee_id,employee_name,employee_salary) & display employee salary in ascending order.

  • functionvincent July 8, 2011 at 10:04 AM

    how to i make up a boolean function to check a string is a interger or not, both postive and negative.

  • arraysfelix June 25, 2011 at 9:26 PM

    I want to change a value in an array but i can't figure out why it doesn't work.here is the code: #include <stdio.h> #define sizeA (9) int main(){ int count,x; int a[sizeA]; int i; int *p=&i; printf("Hello user! Please submit 10 integers (%d):\n",sizeA); for (i = 0; i < sizeA; i++) scanf("%d", &a[i]); printf("Enter the position of the entry you want to change (or 0 to quit):"); scanf("%d", p); printf("Enter the New entry: "); scanf("%d", *p); printf("\nNew entry is %d.", a[i]); }

  • link error naya July 11, 2011 at 7:14 PM

    I am using a header file containing a function prototype, a .cpp file containing function's definition and a main program from which I am trying to call the function but it doesn't work. Here are the code fragments: ------stree.h Header file-------- #define NUMSTRBITS 13 #define STRLENBITS 19 #define MAXNUMSTR (1 << NUMSTRBITS) #define MAXSTRLEN (1 << STRLENBITS) #define MAXNUMNODES (1 << 23) #define MAXALPHA (1 << 7) #define STREE_DNA -1 #define STREE_RNA -1 #define STREE_PROTEIN -2 #define STREE_ASCII 10 //128 struct stree_node ; typedef struct stree_intleaf { unsigned int strid : NUMSTRBITS; unsigned int pos : STRLENBITS; struct stree_intleaf *next; struct stree_node *nextchild; } SINTLEAF_STRUCT, *STREE_INTLEAF; typedef struct stree_leaf { unsigned int id : 23; unsigned int isaleaf : 1; unsigned int nextisparent : 1; unsigned int ch : 7; struct stree_node *next; unsigned int strid : NUMSTRBITS; unsigned int pos : STRLENBITS; } SLEAF_STRUCT, *STREE_LEAF; typedef struct stree_node { unsigned int id : 23; unsigned int isaleaf : 1; unsigned int nextisparent : 1; unsigned int ch : 7; struct stree_node *next; struct stree_node *children; struct stree_node *suffix_link; char *edgestr; int edgelen; } SNODE_STRUCT, *STREE_NODE; typedef struct { STREE_NODE root; int num_nodes; char **strings; int *lengths, *ids; int nextslot, copyflag; int alpha_size, idents_dirty; char *alpha_map; } STREE_STRUCT, *SUFFIX_TREE; SUFFIX_TREE stree_new_tree(int alphabet, int copyflag); ... ---------stree.c file---------- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <assert.h> #include "stree.h" static int initmaps = 0; static char dnamap[128], proteinmap[128], selfmap[10]; //selfmap[128]; static void int_stree_init_alphamaps(void); static int max_alloc = 0; int cur_alloc = 0; SUFFIX_TREE stree_new_tree(int alphabet, int copyflag) { SUFFIX_TREE tree; if (alphabet > MAXALPHA || (alphabet <= 0 && alphabet != STREE_DNA && alphabet != STREE_PROTEIN)) return NULL; if (!initmaps) int_stree_init_alphamaps(); /* * Allocate the space. */ if ((tree = malloc(sizeof(STREE_STRUCT))) == NULL) return NULL; memset(tree, 0, sizeof(STREE_STRUCT)); if ((tree->strings = malloc(MAXNUMSTR * sizeof(char *))) == NULL || (tree->lengths = malloc(MAXNUMSTR * sizeof(int))) == NULL || (tree->ids = malloc(MAXNUMSTR * sizeof(int))) == NULL || (tree->root = int_stree_new_node(tree, NULL, 0)) == NULL) { if (tree->strings != NULL) free(tree->strings); if (tree->lengths != NULL) free(tree->lengths); if (tree->ids != NULL) free(tree->ids); if (tree->root != NULL) int_stree_free_node(tree, tree->root); free(tree); return NULL; } memset(tree->strings, 0, MAXNUMSTR * sizeof(char *)); tree->num_nodes = 1; tree->copyflag = copyflag; if (alphabet == STREE_DNA) { tree->alpha_size = 4; tree->alpha_map = dnamap; } else if (alphabet == STREE_PROTEIN) { tree->alpha_size = 20; tree->alpha_map = proteinmap; } else { tree->alpha_size = alphabet; tree->alpha_map = selfmap; } tree->root->nextisparent = 1; return tree; } ........... ----------main file-------- #include <iostream> #include <malloc.h> #include <conio.h> #include <math.h> #include <time.h> #include <string.h> #include <fstream> #include "stree.h" int main() { SUFFIX_TREE tree1; tree1=stree_new_tree(5,0); }

  • About sorting vector classesTed August 22, 2011 at 7:37 PM

    Hi there, I have a vector of such class: class Appt { public: int day; int month; int year; string SingleAppoint; int ageAppt; } Basically I am trying to compare the ageAppt stored in the vector appointments (vector<Appt>appointments) so as to rearrange the elements in the array in an ascending order according to ageAppt. I am not sure whether I could do this using a sort function. I got a massive block of error codes relating to the this. Here is my code: bool compareVector(appointments[i].ageAppt1,appointments[j].ageAppt2) { return (i<j);} void updateVector(vector<Appt>&appointments) { Appt use; for(unsigned i=0;i<appointments.size();i++) { appointments[i].ageAppt = use.convertageAppt(appointments[i].day,appointments[i].month,appointments[i].year); } sort (appointments.begin(),appointments.end(),compareVector); for(unsigned j=0;j<appointments.size();j++) { cout<<appointments[j].SingleAppoint<<endl; } Any advice on how to do this is appreciated.

  • strncmpGregg August 27, 2011 at 4:25 AM

    I am having a challenge getting compile errors on a strncmp. any suggestions here? char Line2[Buffer]; int Byte = 0; while(strncmp(Line2[Byte],",",1) != 0) <-- Compile error Error is invalid conversion from 'char' to 'const char*' Any help would be appreciated

  • Language C PrecedenceManish Gupta August 27, 2011 at 12:02 PM

    b = 0x80; if(b&0x80 != 0) is False but when b = 0xFF; if(b&0x80 != 0) is True How?

  • C++MANMOHAN SHARMA June 4, 2013 at 10:29 PM

    Please solve this : "Write a function to find out common alphabets between two arrays. Length of array is not fixed and may contain other data type also.â??

  • Sizeof Operator in C programmingUppala Vikram June 6, 2013 at 10:47 PM

    will it possible to implement userdefined function to implement the sizeof operation.if yes kindly explain the process for the same

  • ask questioned cepaitis September 7, 2011 at 10:22 AM

    how big is kim kardashians diamond

  • Function Overloadingeda May 24, 2013 at 12:50 PM

    I will calculate area and volume of cylinder with respect to this rules. 1. radius and heigt will have to input from keyboard but you gave value them and as double. 2. r and h can input from keyboard and may be integer, double or float so that calculation of volume() and area() can give permission to the polymorphism. Program will understand to the function type automatically. 3.Area() and Volume() functions must be declared as a class of member functions #include<iostream> #include<conio.h> using namespace std; const float PI=3.14; class cylinder{ double r, h; public: double area(); double volume(); double volume(double radius,double height){ r=radius; h=height; return PI*r*r*h; } double area(double radius,double height){ r=radius; h=height; return 2*PI*r*r*+2*PI*r*h; } }c; int main() { int ch; cylinder c; c.r; c.h; double area(x,y); double volume(x,y); cout<<"\tCALCULATION OF AREA AND VOLUME"; cout<<"\n1.Area of the cylinder"; cout<<"\n2. Volume of the cylinder"; cout<<"\n\tEnter your choice "; cin>>ch; switch(ch) { case 1: cout<<"\nEnter the radius"; cin>>x; cout<<"\nEnter the height"; cin>>y; break; case 2: cout<<"\nEnter the radius"; cin>>x; cout<<"\nEnter the height"; cin>>y; break; default: cout<<"\nThe choice entered is a wrong choice"; cout<< "Area =" << c.area() << "\n"; cout<< "Volume=" << c.volume() << "\n"; } getch(); } Thank you

  • programing Calfred March 2, 2013 at 1:55 PM

    write a complete c program that computes the product of 2 decimal integers and print the result

  • Questions from C++ Saurav September 23, 2011 at 3:15 PM

    What will be the value of:- #include<iostream.h> #include<conio.h> int main() { int i=340*100; clrscr(); cout<<i; getch(); return 0; }

  • count sun,mon,tue,wed,thu,fri,satamit September 26, 2011 at 6:12 PM

    pls give solution for calculating total number of sunday,mon,tue,wed,thu,fri,sat from a given date 25/2/2010 to 25 /2 /2011 in c language

  • sending data to serverEni September 29, 2011 at 4:25 PM

    How can i make a portable program like msn but for another website. My purpouse is to send data from program and not from HTML form from web browser. I mean to make a logging program for windows7, Just logging in program and not in the website. critics accepted !!! "trying to fix the entire world" not NWO but i need help, i cant do it all myself...

  • C++Amit February 5, 2013 at 2:36 AM

    Hello, Can any one explain me with the following code output?? #include<iostream.h> #include<stdlib.h> void main() { randomize(); int guess, high=4; guess=random(high)=4; for(int c=guess; c<=55; c++) cout<<c<<"#"; }

  • C++Amit February 5, 2013 at 2:44 AM

    Hie, would u please help me with the following code output. void main() { int track[]={10,20,30,40}, *striker; striker=track; track[1]+=30; cout<<"striker>"<<*striker<<endl; *striker-=10; striker++; cout<<"next@"<<*striker<<endl; stricker+=2; cout<<"last@"<<*striker<<endl; cout<<"reset to"<<track[0]<<endl; } i know the output but how dont knw...also i didn't get the difference between *striker and striker please help thanku :)

  • c++feeling heart February 19, 2013 at 2:54 PM

    A balance has the following size weights: 100 lb, 50 lb, 10 lb, 5 lb, and 1 lb. The number of 100 lb and 50 lb weights required to weigh an object weighing weight pounds can be calculated by using the following C++ statements: // Determine the number of 100 lb weights w100 = int(weight/100) // Determine the number of 50 lb weights w50 = int((weight â?? w100 * 100)/50) Using these statements as a starting point, write a C++ program that accepts a weight input from the user and then calculates the number of each type of weight needed to weigh that object.

  • c++feeling heart February 19, 2013 at 5:34 PM

    A balance has the following size weights: 100 lb, 50 lb, 10 lb, 5 lb, and 1 lb. The number of 100 lb and 50 lb weights required to weigh an object weighing weight pounds can be calculated by using the following C++ statements: // Determine the number of 100 lb weights w100 = int(weight/100) // Determine the number of 50 lb weights w50 = int((weight – w100 * 100)/50) Using these statements as a starting point, write a C++ program that accepts a weight input from the user and then calculates the number of each type of weight needed to weigh that object.

  • C++Rushab October 6, 2011 at 4:46 PM

    write a program that declares variables to represent the length and width of a room in meter use room as the class name. Assign appropriate values to the variables- for example length=15 and width=22.5. compute and display the floor of the room in square meter (area= length*width). Display more than just a value as output; also display explanatory text with the value - for example, The floor space is 337.50 square meter

  • c expressionsbalu February 1, 2013 at 2:46 PM

    1.printf("%d",i++ + i++ + i++) ; output is 6 2.printf("%d",i+ i++ + i) ; output is 5 i think expression evaluated from left to right .. 1st one is fyn. but how second one works. i expect its output as 1+1+2 =4 but why its 5..??

  • tic - tac - toe (c++)sara February 6, 2013 at 7:09 PM

    why this program is not working? it says vector subscript is out of range. const char X = 'X'; const char O = 'O'; const char EMPTY = ' '; const char TIE = 'T'; const char NO_ONE = 'N'; // function prototypes void instructions(); char askYesNo(string question); int askNumber(string question, int high, int low = 0); char humanPiece(); char opponent(char piece); void displayBoard(const vector<char>& board); char winner(const vector<char>& board); bool isLegal(const vector<char>& board, int move); int humanMove(const vector<char>& board, char human); int computerMove(vector<char> board, char computer); void announceWinner(char winner, char computer, char human); // main function int main() { int move; const int NUM_SQUARES = 9; vector<char> board(NUM_SQUARES, EMPTY);//empty kardane 9 ta moraba instructions(); char human = humanPiece(); char computer = opponent(human); char turn = X; displayBoard(board); while (winner(board) == NO_ONE) { if (turn == human) { move = humanMove(board, human); board[move] = human; } else { move = computerMove(board, computer); board[move] = computer; } displayBoard(board); turn = opponent(turn); } announceWinner(winner(board), computer, human); return 0; } void instructions() { cout << "Welcome to the Tic-Tac-Toe.\n"; cout << "Make your move known by entering a number, 0 - 8. The number\n"; cout << "corresponds to the desired board position, as illustrated:\n\n"; cout << " 0 | 1 | 2\n"; cout << " â??â??â??â??â??â??â?? \n"; cout << " 3 | 4 | 5\n"; cout << " â??â??â??â??â??â??â?? \n"; cout << " 6 | 7 | 8\n\n"; cout << "Prepare yourself, human. The battle is about to begin.\n\n"; } char humanPiece() { char go_first = askYesNo("Do you require the first move?"); if (go_first == 'y') { cout << "\nThen take the first move. You will need it.\n"; return X; } else { cout << "\nYour bravery will be your undoing. . . I will go first.\n"; return O; } } char askYesNo(string question) { char response; do { cout << question << " (y/n): "; cin >> response; } while (response != 'y' && response != 'n'); return response; } char opponent(char piece) { if (piece == X) { return O; } else { return X; } } void displayBoard(const vector<char>& board) { cout << "\n\t" << board[0] << " | " << board[1] << " | " << board[2]; cout << "\n\t" << "â??â??â??â??â??â??â??"; cout << "\n\t" << board[3] << " | " << board[4] << " | " << board[5]; cout << "\n\t" << "â??â??â??â??â??â??â??"; cout << "\n\t" << board[6] << " | " << board[7] << " | " << board[8]; cout << "\n\n"; } char winner(const vector<char>& board) { // all possible winning rows const int WINNING_ROWS[8][3] = { {0, 1, 2},{3, 4, 5},{6, 7, 8},{0, 3, 6},{1, 4, 7},{2, 5, 8},{0, 4, 8},{2, 4, 6} }; const int TOTAL_ROWS = 8; // if any winning row has three values that are the same (and not EMPTY), // then we have a winner for(int row = 0; row < TOTAL_ROWS; ++row) { if ( (board[WINNING_ROWS[row][0]] != EMPTY) &&(board[WINNING_ROWS[row][0]] == board[WINNING_ROWS[row][1]]) &&(board[WINNING_ROWS[row][1]] == board[WINNING_ROWS[row][2]]) ) { return board[WINNING_ROWS[row][0]]; } } // since nobody has won, check for a tie (no empty squares left) if (count(board.begin(), board.end(), EMPTY) == 0) return TIE; // since nobody has won and it isnâ??t a tie, the game ainâ??t over return NO_ONE; } inline bool isLegal(int move, const vector<char>& board) { return (board[move] == EMPTY); } int humanMove(const vector<char>& board, char human) { int move = askNumber("Where will you move?", (board.size() - 1)); while (!isLegal(move, board)) { cout << "\nThat square is already occupied, foolish human.\n"; move = askNumber("Where will you move?", (board.size() - 1)); } cout << "Fine. . .\n"; return move; } int askNumber(string question, int high, int low) { int number; do { cout << question << " (" << low << " - " << high << "): "; cin >> number; } while (number > high || number < low); return number; } int computerMove(vector<char> board, char computer) { unsigned int move = 0; bool found = false; //if computer can win on next move, thatâ??s the move to make while (!found && move < board.size()) { if (isLegal(move, board)) { board[move] = computer; found = winner(board) == computer; board[move] = EMPTY; } if (!found) { ++move; } } //otherwise, if human can win on next move, thatâ??s the move to make if (!found) { move = 0; char human = opponent(computer); while (!found && move < board.size()) { if (isLegal(move, board)) { board[move] = human; found = winner(board) == human; board[move] = EMPTY; } if (!found) { ++move; } } } cout << "I shall take square number " << move << endl; return move; } void announceWinner(char winner, char computer, char human) { if (winner == computer) { cout << winner << "â??s won!\n"; cout << "As I predicted, human, I am triumphant once more -- proof\n"; cout << "that computers are superior to humans in all regards.\n"; } else if (winner == human) { cout << winner << "â??s won!\n"; cout << "No, no! It cannot be! Somehow you tricked me, human.\n"; cout << "But never again! I, the computer, so swear it!\n"; } else { cout << "Itâ??s a tie.\n"; cout << "You were most lucky, human, and somehow managed to tie me.\n"; cout << "Celebrate. . . for this is the best you will ever achieve.\n"; } }

  • Plz help me, got stock ..hola February 10, 2013 at 9:53 PM

    Hi guys, I have 2 c program file, one of them is the main, and the other is data_file.txt . I'm using Linux computer, and cant run the program. first, I put both files in my home, then I wrote this: ./main data_file.txt but everytime get this commment: permission denied. plz hellllllllllllllllllllllp...

  • Help Me With this taskRai Gledly October 13, 2011 at 6:34 PM

    please help me how to make coding the results like this Input date = 20/12/1920 Input date = 20/12/1910 Input date = 12/11/1980 Input date = 15/6/2020 Input date = 0/0/0 -- if i write down this number the program automatically will be stop -- The Oldest date is = 20\12\1910 I Really hope for the help o:)

  • c++ for practicle helpanil October 18, 2011 at 12:08 AM

    WAP to compute the sum of the first n terms of the following series S =1-2+3-4+5…………….

  • c code for stiff ordinary coupled equationssandeep k February 13, 2013 at 3:57 PM

    time derivative of(I1) =(G1-a-g*e*I1-2*e*((1-g)*I2+(1-g)*I3))*I1; time derivative of (G1)=(r-(1+I1+b*(I2+I3))*G1)*tc/tf; I2 dot = (G2-a-g*e*I2-2*e*((1-g)*I1+g*I3))*I2; G2 dot=(r-(1+I2+b*(I1+I3))*G2)*tc/tf; I3 dot=(G3-a-g*e*I3-2*e*((1-g)*I1+g*I2))*I3; G3 dot=ret=(r-(1+I3+b*(I1+I2))*G3)*tc/tf; can anybody please solve this ...this can't be solved using rk4.I will give you the constant values double g =0.42; double tf =240*pow(10,-6); double tc =0.2*pow(10,-9); double a= 0.01; double e =5.0*pow(10,-5); double b=0.7; double r=0.05; initial conditions are I1 = 1.0; I2 = 2.0; I3 = 3.0; G1 = 4.0; G2 = 5.5; G3 = 6.2;

  • C LanguageKamran Khan October 30, 2011 at 4:56 PM

    Get Parent Process ID Fork () Call Execution Fork () Call Result, ID for Child Process Stable Parent Process ID before and after fork() call Displaying â??I AM CHILD PROCESSâ?? Displaying â??I AM PARENT PROCESSâ??

  • C LanguageKamran Khan October 30, 2011 at 4:57 PM

    Get Parent Process ID Fork () Call Execution Fork () Call Result, ID for Child Process Stable Parent Process ID before and after fork() call Displaying â??I AM CHILD PROCESSâ?? Displaying â??I AM PARENT PROCESSâ??

  • C++ funtionsGerry October 31, 2011 at 11:14 PM

    Write a program to find x (a number greater than or equal to 1 and less than or equal to 9) that satisfies the following equation: (x/x) – (x/2) + (x/4) = (x/12)

  • C++ funtionsGerry October 31, 2011 at 11:16 PM

    Write a program to find x (a number greater than or equal to 1 and less than or equal to 9) that satisfies the following equation: (x/x) – (x/2) + (x/4) = (x/12)

  • C++ , _lp64honest November 4, 2011 at 2:06 PM

    what is this part of this program means: (it's part of a program) #if defined(_LP64) typedef unsigned int uint32; #else typedef unsigned long uint32; #endif i know it's define int or long 32bit; but when the first condition is true and when the second condition? how it decide to chose these condition? tanx. MSP.

  • cJ v November 6, 2011 at 8:54 AM

    in c programming language can i write a loop as given below, for(i=1;i<30;i+2) { printf"i"; } If possible pleas explain the working of nested loops also.. thnk u

  • Having problem with STACKgimbilak November 11, 2011 at 7:36 PM

    i know this question is very simple but i dont know how to write an easy C++ programm using Stack,i wll very thank full if somebody help me my question : write a C++ programm that print 10 int in reverse with stack thank you

  • Q1: for the C++Hamed Almazyadi November 21, 2011 at 10:31 PM

    An integer is divisible by 9 if the sum of its digits iss divisible by 9. use this idea to write a program to determine whether a given integer is divisible by 9 .(using while loop).

  • running time of the programhonest.m December 5, 2011 at 3:53 AM

    hi, is writing comments in the program have any effect on the running time of the program. its means that is writing comments in the source code make program slower or not? thanks msp.

  • function callshonest.m December 5, 2011 at 4:01 AM

    dose function calls have any effect on running time of the program? is it make program slower or faster? for example i write a program withe c++ that sum two number. is it better to write it as an function and then call it in int-main function or do other work, write it completely and straight in int-main ? which one is faster?

  • difference between c++ and matlabhonest.m December 5, 2011 at 4:05 AM

    why c++ is very faster than matlab? what is the differences between them? what is the problem of matlab that makes it slower? thanks. msp

  • 2D Arraysven December 18, 2011 at 9:56 AM

    everyone, i got a question here..how to input a name in 2D array..

  • C++Hosein March 14, 2013 at 2:04 AM

    HI If you have several square each side of the square is a number how the same numbers together

  • programming c++saurabh December 20, 2011 at 9:37 PM

    automatic variable are stored in a-stack segment b-data segment c-both a and b d-none of these

  • program in c++HASAN ALI January 4, 2012 at 8:36 PM

    I WANT TO WRITE A PROGRAM TO ADD, DELETE, SHOW LIST OF EMPLOYEES IN C++, BELOW IS THE PROGRAM BUT IT IS NOR WORKING PROPERLY, CAN YOU SUGGEST THE CHANGES NEEDED, PKZ MAIL ME #include <iostream> using namespace std; class Employee { private: char emp[10]; int pho; int id,q; public: void print() { cout<<endl<<"Employee name :"<<emp<<endl; cout<<"Phone : "<<pho<<endl; if(id<=5); int t=1; printf("employee id=%d\n",t); t++; } void get() { cout<<"Enter employee name : "; cin>>emp; cout<<endl<<"Enter phone no. :"; cin>>pho; } }; int main() { int q,n,j=0,t=1; Employee empp[10]; do { again:printf("enter 1 to add employee\n"); printf("enter 2 to show list of the employees\n"); printf("enter 3 to exit\n"); scanf("%d",&q); if(q==1) { printf("enter no. of employees u want to add\n"); scanf("%d",&n); for(int i=0;i<n;i++) { empp[i].get(); } j=j+n; goto again; } if(q==2) { if(j==0) { printf("So far No employees in the company\n"); goto again; } printf("\nThe List of employees are\n"); for(int i=0;i<j;i++) { empp[i].print(); } goto again; } if(q==3) { printf("you are out of the program\n thank you\n"); exit(0); } else { printf("you have entered wrong choice\n"); goto again; } } while(q==1); return 0; }

  • programmingsoodalai January 15, 2013 at 8:29 AM

    main() { char *x="girl"; int n,i; n=strlen(x); *x=x[n];//g will be replaced by \0 for(i=0;i<n;i++) { printf("%s \n",x);// //irl//rl//r// x++; } }

  • Help to write a c programTameka Watson January 16, 2013 at 7:10 PM

    Need help to write a c program with three operations addition, subtraction and multplication- the users should be allowed to enter two numbers with none exceeding 70. if the number. the user should be prompted if number is out of range

  • c++ program for matrixTejas January 20, 2012 at 1:27 PM

    hi there i want the c++ program for the following solution. Enter the no. of rows/columns: 3/3 Enter 1st row: 1 1 1 Enter 2nd row: 2 2 2 Enter 3rd row: 3 3 3 1 1 1 2 2 2 3 3 3 and moreover while i input element it also should appear in the resulting matrix the same time. i.e. enter the 1st row: 1 1 i.e. enter the 1st row: 1 1 1 1

  • didnt understand the codes... plz explainsneha rane January 21, 2012 at 12:13 PM

    /* Developed by "akshay kumar srivastava"*/ /* phone 09835457174 oct 2005*/ /* aks_mailin@rediffmail.com*/ /* dont press Esc key at start of game*/ #include<stdio.h> #include<graphics.h> #include<conio.h> #include<dos.h> #include<math.h> #include<stdlib.h> /* MOUSE FUNCTIONS FOR LUDO GAME */ int DetectMouse(void); void InitMouse(void); void ShowMouse(void); void HideMouse(void); void WhereMouse(int*,int*); int ButtClicked(void); int ButtReleased(void); int DetectMouse(void){ union REGS in,out; in.x.ax=0; int86(0x33,&in,&out); if(out.x.ax==0) return(0); else return(1); } void InitMouse(void) { union REGS in,out; in.x.ax=33; int86(0x33,&in,&out); return; } void HideMouse(void) { union REGS in,out; in.x.ax=2; int86(0x33,&in,&out); return; } void ShowMouse(void) { union REGS in,out; in.x.ax=1; int86(0x33,&in,&out); return; } void WhereMouse(int *x,int *y) { union REGS in,out; in.x.ax=3; int86(0x33,&in,&out); *x=(int)out.x.cx; *y=(int)out.x.dx; return; } int ButtClicked(void){ union REGS imouse,omouse; int mc,mr; imouse.x.ax = 3; int86(0x33,&imouse,&omouse); mc=omouse.x.bx; return(mc); } int ButtReleased(void){ int br; br=ButtClicked(); do{}while(ButtClicked()!=0); return br; } /* GLOBAL VARIABLES */ int background=0; int colorfortext=WHITE;//color used to display text int rec=MAGENTA;//color for border of rectangles int flagturn;//players turn=0 computer=1 int for6=0;//for 6 to come at regular intervals int dice_value_color[4]; /* USER DEFINED FUNCTIONS */ void draw_all(void); int player_chooses_house_color(void); void draw_house(int color_of_house,int top_left_x_coordinate,int top_left_y_coordinate); void draw_button_with_button_name(int top_left_x_coordinate,int top_left_y_coordinate,char* button_name); void show_mouse_click_on_button(int mouse_click_x_coordinate,int mouse_click_y_coordinate); int check_if_mouse_click_is_on_any_button (int mouse_click_x_coordinate,int mouse_click_y_coordinate); void throw1(int x_coordinate_for_dice ,int y_coordinate_for_dice,int counter_for_wait_at_last ,char dice_value); void throw2(int x_coordinate_for_dice ,int y_coordinate_for_dice,char dice_value); int throwdice(void); void messageout(char *message,int refresh_message=1); void messageclear(void); void initialise_house_with_ludos(int color_of_house); void load_path_information_in_ludos(int ludo_house_color); void winner(void); void about(void); void howtoplay(void); void redrawing(int ); int catchclickonludobutton(void) ; int forcomputer1(int); int forcomputer2(int); int forcomputer3(int); struct ludo{ int x[45]; int y[45]; int pos; int color; void (*ptr_ludo1)(int,int*,int*,ludo *); int (*ptr_check_if_ludo_move_requested_is_valid)(int ,ludo*); void (*ptr_move_ludo_to_new_position)( int ,ludo*); }; struct ludo lp[4],lc1[4],lc2[4],lc3[4]; /* ludo1 initialises the ludo class objects */ void ludo1(int col,int *ax,int *ay,ludo *node) { int i; for(i=0;i<=44;i++) { node->x[i]=*(ax); node->y[i]=*(ay); ax++;ay++; } node->color=col; node->pos=0; }//end of ludo1 int check_if_ludo_move_requested_is_valid(int dice,ludo *node) { /*return 1 move valid i.e proceed to movetopos,0 if not valid 2 if player cannot move any ludo*/ int i,j=0; if( (node->pos<=44-dice && node->pos!=0) || (node->pos==0 && dice==6) ) return(1); // ludo can move for(i=0;i<=3;i++) { if( (lp[i].pos+dice<=44 && lp[i].pos!=0) || (lp[i].pos==0 && dice==6) ) j=1;//i.e there is atleast one ludo which //can move with current dice value } if(j>0) return(2);//choose the correct ludo that can move else return(3);//no ludo can move at current dice value //and player has to skip chance }//end of check_if_ludo_move_requested_is_valid void move_ludo_to_new_position( int dice ,ludo *node) { HideMouse(); if(node->pos==0 && dice==6)//taking out of house on dice givig 6 { messageclear();dice=1;} dice=dice-1; int opos; opos=node->pos; int i; for(i=opos;i<=dice+opos;i++) { setcolor(7); circle(node->x[i],node->y[i],8); setfillstyle(1,7); floodfill(node->x[i],node->y[i],7); delay(50); {node->pos++; redrawing(node->color);} setcolor(node->color); circle(node->x[i+1],node->y[i+1],8); setfillstyle(1,node->color); floodfill(node->x[i+1],node->y[i+1],node->color); delay(50); } /*changing pos to 0 if ludo has been cut before redrawing all ludos*/ for(i=0;i<=3;i++) { if(node->x[node->pos]==lp[i].x[lp[i].pos] && node->y[node->pos]==lp[i].y[lp[i].pos] ) { if(node->color!=lp[i].color) lp[i].pos=0; } if(node->x[node->pos]==lc1[i].x[lc1[i].pos] && node->y[node->pos]==lc1[i].y[lc1[i].pos] ) { if(node->color!=lc1[i].color) lc1[i].pos=0; } if(node->x[node->pos]==lc2[i].x[lc2[i].pos] && node->y[node->pos]==lc2[i].y[lc2[i].pos] ) { if(node->color!=lc2[i].color) lc2[i].pos=0; } if(node->x[node->pos]==lc3[i].x[lc3[i].pos] && node->y[node->pos]==lc3[i].y[lc3[i].pos] ) { if(node->color!=lc3[i].color) lc3[i].pos=0; } }// end of for /* redrawing new positions of all ludos */ redrawing(lp[0].color); redrawing(lc1[0].color); redrawing(lc2[0].color); redrawing(lc3[0].color); /* to check who is the winner */ static int number_of_player_ludo_home=0; static int number_of_computer1_ludo_home=0; static int number_of_computer2_ludo_home=0; static int number_of_computer3_ludo_home=0; if(node->pos==44 && flagturn==0) number_of_player_ludo_home++; if(node->pos==44 && flagturn==1) number_of_computer1_ludo_home++; if(node->pos==44 && flagturn==2) number_of_computer2_ludo_home++; if(node->pos==44 && flagturn==3) number_of_computer3_ludo_home++; if(number_of_player_ludo_home==4) winner(); if(number_of_computer1_ludo_home==4) winner(); if(number_of_computer2_ludo_home==4) winner(); if(number_of_computer3_ludo_home==4) winner(); ShowMouse(); } //end of move_ludo_to_new_position //end of ludo class //struct ludo lp[4],lc1[4],lc2[4],lc3[4]; void changingcpptoc(void) { //struct ludo lp[4],lc1[4],lc2[4],lc3[4]; int zx; for( zx=0;zx<4;zx++) { lp[zx].ptr_ludo1=ludo1; lc1[zx].ptr_ludo1=ludo1; lc2[zx].ptr_ludo1=ludo1; lc3[zx].ptr_ludo1=ludo1; lp[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_reques ted_is_valid; lc1[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_reque sted_is_valid;; lc2[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_reque sted_is_valid;; lc3[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_reque sted_is_valid;; lp[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position; lc1[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position; lc2[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position; lc3[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position; //int (*ptr_check_if_ludo_move_requested_is_valid)(int ); //void (*ptr_move_ludo_to_new_position)( int ); }//for zx loop ends } void main() { changingcpptoc(); int colors[4]={RED,BLUE,YELLOW,GREEN}; int i,a,b,dice=0,playercolor;; draw_all(); InitMouse(); ShowMouse(); playercolor=player_chooses_house_color(); flagturn=0; dice_value_color[flagturn]=playercolor; load_path_information_in_ludos(playercolor);//gives life to correct color ludo as path depends on color /* this code helps in making the chance of throwing dice go in a clockwise mode what color may the player choose to play*/ i=3; while(i) { if(colors[i]==playercolor) break; i--; } int loop=i; while(1) { flagturn++; loop++; if(loop>=4) loop=0; load_path_information_in_ludos(colors[loop]); dice_value_color[flagturn]=colors[loop]; if(flagturn==3) break; } initialise_house_with_ludos(RED); initialise_house_with_ludos(BLUE); initialise_house_with_ludos(YELLOW); initialise_house_with_ludos(GREEN); flagturn=0; char ch; int check,tmp1=0,tmp2; enum choose {yes,nomore}; choose choose1=yes; delay(500); messageclear(); while(ch!=27) { if(kbhit()) ch=getch(); setcolor(RED); WhereMouse(&a,&b); if(ButtReleased()) { check=check_if_mouse_click_is_on_any_button (a,b); if(check>=1 && check<=4) show_mouse_click_on_button(a,b); switch(check) { case 1: {about();break;} case 4: {howtoplay(); break;} case 3: {exit(0);break;} case 2: {dice=throwdice(); break;} } //end of switch } //end of if(ButtRelease) /* players chance*/ if(flagturn==0) { messageout("PLAYER throwdice.best of luck. ",0); if(dice!=0) { if(dice==6) messageout("click on ludo button to take out of house or move"); else messageout("click on the ludo button to move"); while(choose1==yes) { choose1=nomore; tmp1=catchclickonludobutton(); tmp2=lp[tmp1].ptr_check_if_ludo_move_requested_is_valid(dice,&lp[tmp1]); switch(tmp2) { case 1: { lp[tmp1].ptr_move_ludo_to_new_position(dice,&lp[tmp1]); messageout("proceeding"); delay(1000); break; } case 2: { messageout("choose correct ludo to proceed"); delay(1000); choose1=yes; break; } case 3: { messageout("sorry,you will have to skip this time"); delay(1000); break; } }//switch ends }//end of while(choose1=yes) flagturn=1; choose1=yes; }//end of if(dice!=0) dice=0; }// end of if(flagturn==0) /*computer1 chance*/ if(flagturn==1) { messageout("now the computer1 will throw dice"); dice=throwdice(); if(dice!=0) { tmp1=forcomputer1(dice); if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move lc1[tmp1].ptr_move_ludo_to_new_position(dice,&lc1[tmp1]); else messageout("computer1 has to skip this time."); } flagturn=2; messageclear(); dice=0; } /*computer2 chance*/ if(flagturn==2) { messageout("now the computer2 will throw dice"); dice=throwdice(); if(dice!=0) { tmp1=forcomputer2(dice); if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move lc2[tmp1].ptr_move_ludo_to_new_position(dice,&lc2[tmp1]); else messageout("computer2 has to skip this time."); } flagturn=3; messageclear(); dice=0; } /*computer3 chance*/ if(flagturn==3) { messageout("now the computer3 will throw dice"); dice=throwdice(); if(dice!=0) { tmp1=forcomputer3(dice); if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move lc3[tmp1].ptr_move_ludo_to_new_position(dice,&lc3[tmp1]); else messageout("computer3 has to skip this time."); } flagturn=0; messageclear(); dice=0; } dice=0; }//end of while }//end of main void draw_house(int col,int x,int y) { setcolor(rec); rectangle(x,y,x+120,y+120); setfillstyle(1,col); floodfill(x+10,y+10,rec); circle(x+30,y+30,10); setfillstyle(1,WHITE); floodfill(x+30,y+30,rec); circle(x+30,y+70,10); setfillstyle(1,WHITE); floodfill(x+30,y+70,rec); circle(x+90,y+30,10); setfillstyle(1,WHITE); floodfill(x+90,y+30,rec); circle(x+90,y+70,10); setfillstyle(1,WHITE); floodfill(x+90,y+70,rec); } void draw_button_with_button_name(int x,int y,char *message) { setcolor(rec); rectangle(x,y,x+110,y+30); setcolor(colorfortext); outtextxy(x+20,y+15,message); } void show_mouse_click_on_button(int x,int y) { HideMouse(); setfillstyle(1,7); floodfill(x,y,rec); delay(50); setfillstyle(1,0); floodfill(x,y,rec); draw_button_with_button_name(0,55,"about"); draw_button_with_button_name(120,55,"exit"); draw_button_with_button_name(0,55+35,"throw dice"); draw_button_with_button_name(120,55+35,"how to play"); ShowMouse(); } int check_if_mouse_click_is_on_any_button (int a,int b) { if(a>0 && a<110 && b>55 && b<85) return 1; else if(a>0 && a<110 && b>90 && b<120) return 2; else if(a>120 && a< 230 && b>55 && b<85) return 3; else if(a>120 && a< 230 && b>90 && b<120) return 4; else if(a>239 && a<359 && b>0 && b<120 ) return 5; else if(a>239 && a<359 && b>280 && b<400 ) return 6; else if(a>519 && a<639 && b>0 && b<120 ) return 7; else if(a>519 && a<659 && b>280 && b<400 ) return 8; else return 0; } int throwdice() { HideMouse(); int rn,count=0;char num; int x=0,y,flag=0; randomize(); for(y=150;y<=320;y=y+10,x=x+10) { rn=random(6)+1; /* using for6 to get a 6 on dice every 5th time to make the game a little faster*/ if(y==320) {for6++;} if(for6>=5) { rn=6; for6=0; } // cout<<for6; //if(y==320) // for6++; num=rn+48; if(flag==0) { throw2(x,y,num); flag=1; } else { count++; throw1(x,y,count,num); flag=0; } } settextstyle(0,0,0); ShowMouse(); return rn; } void throw1(int x,int y,int count,char num) { settextstyle(0,0,3); setcolor(WHITE); rectangle(x,y,x+35,y+35); //setcolor(RED); setcolor(dice_value_color[flagturn]); outtextxy(x+5,y+5,&num); delay(140); if(count==9) {delay(650); } setcolor(0); rectangle(x,y,x+35,y+35); outtextxy(x+5,y+5,&num); } void throw2(int x,int y,char num) { x=x-17;y=y+10; settextstyle(0,0,3); setcolor(WHITE); line(x,y,x+25,y+25); line(x,y,x+25,y-25); line(x+25,y+25,x+50,y); line(x+25,y-25,x+50,y); //setcolor(RED); setcolor(dice_value_color[flagturn]); outtextxy(x+15,y-10,&num); delay(140); setcolor(0); line(x,y,x+25,y+25); line(x,y,x+25,y-25); line(x+25,y+25,x+50,y); line(x+25,y-25,x+50,y); outtextxy(x+15,y-10,&num); } void messageout(char *message,int refresh) { if(refresh) messageclear(); setcolor(colorfortext); outtextxy(20,450,message); } void messageclear() { HideMouse(); setfillstyle(1,0); floodfill(20,450,rec); ShowMouse(); } void initialise_house_with_ludos(int color) { int x,y; switch(color) { case RED: {x=239;y=0;break;} case BLUE: {x=519;y=0;break;} case YELLOW: {x=639-120;y=280;break;} case GREEN: {x=239;y=280;break;} } draw_house(color,x,y); setcolor(rec); setfillstyle(1,color); { circle(x+30,y+30,8); floodfill(x+30,y+30,rec); } { circle(x+30,y+70,8); floodfill(x+30,y+70,rec); } { circle(x+90,y+30,8); floodfill(x+90,y+30,rec); } { circle(x+90,y+70,8); floodfill(x+90,y+70,rec); } } void load_path_information_in_ludos(int plcol) { int arx[45],ary[45]; switch(plcol) { case RED: { int arx[45]={269,284,314,344,379,379,379,379,379,439,499,499,499, 499,499,534,564,594,624,624,624,594,564,534,499, 499,499,499,499,439,384,384,384,384,384,344,314,284, 254,254,284,314,344,384,424}; int ary[45]={30,140,140,140,140,105,75,45,15,15,15,45,75,105,140,140, 140,140,140,200,260,260,260,260,260,295,325,355,385,385, 385,355,325,295,260,260,260,260,260,200,200,200,200,200, 200}; for(int tmp=0;tmp<=3;tmp++) { switch(tmp) { case 0: {arx[0]=269;ary[0]=30;break;} case 1: {arx[0]=329;ary[0]=70;break;} case 2: {arx[0]=329;ary[0]=30;break;} case 3: {arx[0]=269;ary[0]=70;break;} } switch(flagturn) { case 0: {lp[tmp].ptr_ludo1(RED,arx,ary,&lp[tmp]);break;} case 1: {lc1[tmp].ptr_ludo1(RED,arx,ary,&lc1[tmp]);break;} case 2: {lc2[tmp].ptr_ludo1(RED,arx,ary,&lc2[tmp]);break;} case 3: {lc3[tmp].ptr_ludo1(RED,arx,ary,&lc3[tmp]);break;} } } break;}//case RED ends case BLUE: { int arx[45]={549,499,499,499,499,534,564,594,624,624,624,594,564, 534,499,499,499,499,499,439,384,384,384,384,384,344, 314,284,254,254,254,284,314,344,379,379,379,379,379, 439,439,439,439,439,439 }; int ary[45]={30,45,75,105,140,140,140,140,140,200,260,260,260,260, 260,295,325,355,385,385,385,355,325,295,260,260,260, 260,260,200,140,140,140,140,140,105,75,45,15,15,45 ,75,105,140,185}; for(int tmp=0;tmp<=3;tmp++) { switch(tmp) { case 0: {arx[0]=549;ary[0]=30;break;} case 1: {arx[0]=549;ary[0]=70;break;} case 2: {arx[0]=609;ary[0]=30;break;} case 3: {arx[0]=609;ary[0]=70;break;} } switch(flagturn) { case 0: {lp[tmp].ptr_ludo1(BLUE,arx,ary,&lp[tmp]);break;} case 1: {lc1[tmp].ptr_ludo1(BLUE,arx,ary,&lc1[tmp]);break;} case 2: {lc2[tmp].ptr_ludo1(BLUE,arx,ary,&lc2[tmp]);break;} case 3: {lc3[tmp].ptr_ludo1(BLUE,arx,ary,&lc3[tmp]);break;} } } break;} case GREEN: { int arx[45]={269,384,384,384,384,344,314,284,254,254,254,284,314, 344,379,379,379,379,379,439,499,499,499,499,499,534, 564,594,624,624,624,594,564,534,499,499,499,499,499, 439,439,439,439,439,439 }; int ary[45]={30,355,325,295,260,260,260, 260,260,200,140,140,140,140,140,105,75,45,15,15,15,45 ,75,105,140,140,140,140,140,200,260,260,260,260, 260,295,325,355,385,385,355,325,295,260,215}; for(int tmp=0;tmp<=3;tmp++) { switch(tmp) { case 0: {arx[0]=269;ary[0]=310;break;} case 1: {arx[0]=329;ary[0]=350;break;} case 2: {arx[0]=329;ary[0]=310;break;} case 3: {arx[0]=269;ary[0]=350;break;} } switch(flagturn) { case 0: {lp[tmp].ptr_ludo1(GREEN,arx,ary,&lp[tmp]);break;} case 1: {lc1[tmp].ptr_ludo1(GREEN,arx,ary,&lc1[tmp]);break;} case 2: {lc2[tmp].ptr_ludo1(GREEN,arx,ary,&lc2[tmp]);break;} case 3: {lc3[tmp].ptr_ludo1(GREEN,arx,ary,&lc3[tmp]);break;} } } break;} case YELLOW: { int arx[45]={549,594,564,534,499,499,499,499,499,439,384,384,384, 384,384,344,314,284,254,254,254,284,314,344,379,379, 379,379,379,439,499,499,499,499,499,534,564,594,624, 624,594,564,534,499,454}; int ary[45]={310,260,260,260,260,295,325,355,385,385,385,355,325,295, 260,260,260,260,260,200,140,140,140,140,140,105,75,45,15, 15,15,45,75,105,140,140,140,140,140,200,200,200,200,200,200}; for(int tmp=0;tmp<=3;tmp++) { switch(tmp) { case 0: {arx[0]=549;ary[0]=310;break;} case 1: {arx[0]=549;ary[0]=350;break;} case 2: {arx[0]=609;ary[0]=310;break;} case 3: {arx[0]=609;ary[0]=350;break;} } switch(flagturn) { case 0: {lp[tmp].ptr_ludo1(YELLOW,arx,ary,&lp[tmp]);break;} case 1: {lc1[tmp].ptr_ludo1(YELLOW,arx,ary,&lc1[tmp]);break;} case 2: {lc2[tmp].ptr_ludo1(YELLOW,arx,ary,&lc2[tmp]);break;} case 3: {lc3[tmp].ptr_ludo1(YELLOW,arx,ary,&lc3[tmp]);break;} } } break;} }//switch ends } int catchclickonludobutton() { int a,b,i; while(1) { WhereMouse(&a,&b); if(ButtReleased()) { for(i=0;i<=3;i++) { if( abs(a-(lp[i].x[lp[i].pos])) < 8 && abs(b-(lp[i].y[lp[i].pos])) < 8 ) return i; } } } } void redrawing(int tmp) { int i; for(i=0;i<=3;i++) { if(tmp==lp[0].color) { setcolor(lp[i].color); circle(lp[i].x[lp[i].pos],lp[i].y[lp[i].pos],8); setfillstyle(1,lp[i].color); floodfill(lp[i].x[lp[i].pos],lp[i].y[lp[i].pos],lp[i].color); } if(tmp==lc1[0].color) { setcolor(lc1[i].color); circle(lc1[i].x[lc1[i].pos],lc1[i].y[lc1[i].pos],8); setfillstyle(1,lc1[i].color); floodfill(lc1[i].x[lc1[i].pos],lc1[i].y[lc1[i].pos],lc1[i].color); } if(tmp==lc2[0].color) { setcolor(lc2[i].color); circle(lc2[i].x[lc2[i].pos],lc2[i].y[lc2[i].pos],8); setfillstyle(1,lc2[i].color); floodfill(lc2[i].x[lc2[i].pos],lc2[i].y[lc2[i].pos],lc2[i].color); } if(tmp==lc3[0].color) { setcolor(lc3[i].color); circle(lc3[i].x[lc3[i].pos],lc3[i].y[lc3[i].pos],8); setfillstyle(1,lc3[i].color); floodfill(lc3[i].x[lc3[i].pos],lc3[i].y[lc3[i].pos],lc3[i].color); } }//for ends } /* deciding for computer1 which ludo to move */ int forcomputer1(int dice) { int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5; /* checking if atleast one ludo can move at current dice value*/ for(i=0;i<=3;i++) { if( (lc1[i].pos<=44-dice && lc1[i].pos!=0) || (lc1[i].pos==0 && dice==6) ) cannotmove=0;//cannotmove=5 then no ludo can move } if(cannotmove==5) return 5; //position of players ludo in terms of computers1 ludo positions for(i=0;i<=3;i++) { for(j=1;j<=40;j++) { if( lc1[0].x[j]==lp[i].x[lp[i].pos] && lc1[0].y[j]==lp[i].y[lp[i].pos]) { poslpforlc[i]=j; } } } //position of computer2 ludo in terms of computer1 ludo positions for(i=4;i<=7;i++) { for(j=1;j<=40;j++) { if( lc1[0].x[j]==lc2[i-4].x[lc2[i-4].pos] && lc1[0].y[j]==lc2[i-4].y[lc2[i-4].pos]) { poslpforlc[i]=j; } } } //position of computer3 ludo in terms of computer1 ludo positions for(i=8;i<=11;i++) { for(j=1;j<=40;j++) { if( lc1[0].x[j]==lc3[i-8].x[lc3[i-8].pos] && lc1[0].y[j]==lc3[i-8].y[lc3[i-8].pos]) { poslpforlc[i]=j; } } }//end of i /*to cut opponents ludo button*/ for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( dice==(poslpforlc[j] - lc1[i].pos) && lc1[i].pos!=0) return i; } } /* to move those ludos which are near the player ludos and have the gretest value of pos i.e position . it means saving the threatened ludo*/ int array[4]={0,0,0,0}; int a1=0,tmp1; for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( (-poslpforlc[j] + lc1[i].pos)<=6 && (-poslpforlc[j] + lc1[i].pos)>=1 && lc1[i].pos+dice<=44 && poslpforlc[j]!=0 && lc1[i].pos<=40 ) {array[i]=lc1[i].pos;} } if(a1<=array[i]) a1=array[i];/* a1 has the greatest pos value */ } if(a1!=0) //to see that at least one ludo is threatened */ { for(i=0;i<=3;i++) //getting the ludo with greatest pos value { if(a1==array[i]) return i; } } //to take out ludo button from house for(i=0;i<=3;i++) { if(dice==6) { if(lc1[i].pos==0 ) return i; } } /*if ludo buttons are outside and option for cutting opponent or taking out own ludo button are not valid , using round robin for selecting ludo to move*/ static int ludolast=0; int firstround=0; for(i=0;i<=3;i++) { if(firstround==0) { if(ludolast!=3) {i=ludolast+1;} firstround++; } if(lc1[i].pos!=0 && lc1[i].pos+dice<=44 ) {ludolast=i;i=4;} if(i==3) i=-1; } return ludolast; //if ludo button is } /* deciding for computer2 which ludo to move */ int forcomputer2(int dice) { int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5; /* checking if atleast one ludo can move at current dice value*/ for(i=0;i<=3;i++) { if( (lc2[i].pos<=44-dice && lc2[i].pos!=0) || (lc2[i].pos==0 && dice==6) ) cannotmove=0;//cannotmove=5 then no ludo can move } if(cannotmove==5) return 5; //position of players ludo in terms of computers2 ludo positions for(i=0;i<=3;i++) { for(j=1;j<=40;j++) { if( lc2[0].x[j]==lp[i].x[lp[i].pos] && lc2[0].y[j]==lp[i].y[lp[i].pos]) { poslpforlc[i]=j; } } } //position of computer1 ludo in terms of computer2 ludo positions for(i=4;i<=7;i++) { for(j=1;j<=40;j++) { if( lc2[0].x[j]==lc1[i-4].x[lc1[i-4].pos] && lc2[0].y[j]==lc1[i-4].y[lc1[i-4].pos]) { poslpforlc[i]=j; } } } //position of computer3 ludo in terms of computer2 ludo positions for(i=8;i<=11;i++) { for(j=1;j<=40;j++) { if( lc2[0].x[j]==lc3[i-8].x[lc3[i-8].pos] && lc2[0].y[j]==lc3[i-8].y[lc3[i-8].pos]) { poslpforlc[i]=j; } } }//end of i for(i=0;i<=11;i++) { } /*to cut opponents ludo button*/ for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( dice==(poslpforlc[j] - lc2[i].pos) && lc2[i].pos!=0) {return i;} } } /* to move those ludos which are near the player ludos and have the gretest value of pos i.e position . it means saving the threatened ludo*/ int array[4]={0,0,0,0}; int a1=0,tmp1; for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( (-poslpforlc[j] + lc2[i].pos)<=6 && (-poslpforlc[j] + lc2[i].pos)>=1 && lc2[i].pos+dice<=44 && poslpforlc[j]!=0 && lc2[i].pos<=40 ) {array[i]=lc2[i].pos;} } if(a1<=array[i]) a1=array[i];/* a1 has the greatest pos value */ } if(a1!=0) //to see that at least one ludo is threatened */ { for(i=0;i<=3;i++) //getting the ludo with greatest pos value { if(a1==array[i]) {return i;} } } //to take out ludo button from house for(i=0;i<=3;i++) { if(dice==6) { if(lc2[i].pos==0 ) {return i;} } } /*if ludo buttons are outside and option for cutting opponent or taking out own ludo button are not valid , using round robin for selecting ludo to move*/ static int ludolast=0; int firstround=0; for(i=0;i<=3;i++) { if(firstround==0) { if(ludolast!=3) {i=ludolast+1;} firstround++; } if(lc2[i].pos!=0 && lc2[i].pos+dice<=44 ) {ludolast=i;i=4;} if(i==3) i=-1; } return ludolast; //if ludo button is } /* deciding for computer3 which ludo to move */ int forcomputer3(int dice) { int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5; /* checking if atleast one ludo can move at current dice value*/ for(i=0;i<=3;i++) { if( (lc3[i].pos<=44-dice && lc3[i].pos!=0) || (lc3[i].pos==0 && dice==6) ) cannotmove=0;//cannotmove=5 then no ludo can move } if(cannotmove==5) return(5); //position of players ludo in terms of computers1 ludo positions for(i=0;i<=3;i++) { for(j=1;j<=40;j++) { if( lc3[0].x[j]==lp[i].x[lp[i].pos] && lc3[0].y[j]==lp[i].y[lp[i].pos]) { poslpforlc[i]=j; } } } //position of computer2 ludo in terms of computer3 ludo positions for(i=4;i<=7;i++) { for(j=1;j<=40;j++) { if( lc3[0].x[j]==lc2[i-4].x[lc2[i-4].pos] && lc3[0].y[j]==lc2[i-4].y[lc2[i-4].pos]) { poslpforlc[i]=j; } } } //position of computer1 ludo in terms of computer3 ludo positions for(i=8;i<=11;i++) { for(j=1;j<=40;j++) { if( lc3[0].x[j]==lc1[i-8].x[lc1[i-8].pos] && lc3[0].y[j]==lc1[i-8].y[lc1[i-8].pos]) { poslpforlc[i]=j; } } }//end of i /*to cut opponents ludo button*/ for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( dice==(poslpforlc[j] - lc3[i].pos) && lc3[i].pos!=0 ) return i; } } /* to move those ludos which are near the player ludos and have the gretest value of pos i.e position . it means saving the threatened ludo*/ int array[4]={0,0,0,0}; int a1=0,tmp1; for(i=0;i<=3;i++) { for(j=0;j<=11;j++) { if( (-poslpforlc[j] + lc3[i].pos)<=6 && (-poslpforlc[j] + lc3[i].pos)>=1 && lc3[i].pos+dice<=44 && lc3[i].pos<=40 && poslpforlc[j]!=0 ) {array[i]=lc3[i].pos;} } if(a1<=array[i]) a1=array[i];/* a1 has the greatest pos value */ } if(a1!=0) //to see that at least one ludo is threatened */ { for(i=0;i<=3;i++) //getting the ludo with greatest pos value { if(a1==array[i]) {return i;} } } //to take out ludo button from house for(i=0;i<=3;i++) { if(dice==6) { if(lc3[i].pos==0 ) return i; } } /*if ludo buttons are outside and option for cutting opponent or taking out own ludo button are not valid , using round robin for selecting ludo to move*/ static int ludolast=0; int firstround=0; for(i=0;i<=3;i++) { if(firstround==0) { if(ludolast!=3) {i=ludolast+1;} firstround++; } if(lc3[i].pos!=0 && lc3[i].pos+dice<=44 ) {ludolast=i;i=4;} if(i==3) i=-1; } return ludolast; //if ludo button is } void draw_all() { //registerbgidriver(EGAVGA_driver); //registerbgifont(sansserif_font); int gdriver = DETECT, gmode; /* request auto detection */ /* initialize graphics mode */ initgraph(&gdriver, &gmode, ""); /* writing text */ setcolor(background); settextstyle(0,0,0); setcolor (colorfortext); outtextxy(5,10,"(aks_mailin@rediffmail.com)"); outtextxy(5,20,"akshay presents"); outtextxy(5,30,"COMPUTER LUDO"); outtextxy(5,40,"GAME"); /* drawing rectangles */ setcolor(rec); rectangle(0,410,639,479); rectangle(0,0,230,50); setcolor(rec); rectangle(239,0,639,400); setfillstyle(1,7); floodfill(310,10,rec); draw_house(RED,239,0); draw_house(GREEN,239,280); draw_house(BLUE,639-120,0); draw_house(YELLOW,639-120,280); draw_button_with_button_name(0,55,"about"); draw_button_with_button_name(120,55,"exit"); draw_button_with_button_name(0,55+35,"throw dice"); draw_button_with_button_name(120,55+35,"how to play"); /*drawing sectors*/ setcolor(0); line(359,30,519,30 ); line(359,60,519,60 ); line(359,90,519,90 ); line(359,120,519,120 ); line(359,280,519,280); line(359,310,519,310); line(359,340,519,340 ); line(359,370,519,370 ); line(239,160,639,160 ); line(239,240,639,240 ); line(269,120,269,280); line(269+30,120,269+30,280 ); line(269+60,120,269+60,280 ); line(269+90,120,269+90,280 ); line(269+130,0,269+130,400 ); line(269+210,0,269+210,400 ); line(269+250,120,269+250,280 ); line(269+280,120,269+280,280 ); line(269+310,120,269+310,280 ); line(269+340,120,269+340,280 ); setfillstyle(1,WHITE); floodfill(439,200,background); setcolor(RED); outtextxy(420,190,"HOME"); return ; } int player_chooses_house_color(void) { char ch; int check; int a,b,playercolor=0; messageout("PLAYER,click YOUR lucky COLOR on the board "); while(ch!=27) { if(playercolor!=0) break;//come out of while if(kbhit()) ch=getch(); setcolor(RED); WhereMouse(&a,&b); if(ButtReleased()) { check=check_if_mouse_click_is_on_any_button (a,b); switch(check) { case 1: {show_mouse_click_on_button(a,b);about();break;} case 4: {show_mouse_click_on_button(a,b);howtoplay(); break;} case 3: {show_mouse_click_on_button(a,b);exit(0);break;} case 5: { messageout( "you have choosen red"); playercolor=RED; break;} case 6: { messageout( "you have choosen green"); playercolor=GREEN; break;} case 7: { messageout( "you have choosen blue"); playercolor=BLUE; break;} case 8: { messageout( "you have choosen yellow"); playercolor=YELLOW; break;} } //end of switch }//end of if(ButtRelease) }//end of while delay(500); return playercolor; } void about(void) { HideMouse(); setcolor(rec); rectangle(0,135,230,390); setcolor(colorfortext); outtextxy(5,150,"WELCOME to ComputerLudo"); outtextxy(5,160,"This software is developed"); outtextxy(5,170,"by"); outtextxy(5,180,""); outtextxy(5,190,""); outtextxy(5,210,"Akshay "); outtextxy(5,230,"U can send suggestions at"); outtextxy(5,240,"my Email:"); outtextxy(5,250,"aks_mailin@rediffmail.com"); outtextxy(5,260,"thanks"); outtextxy(5,310,"PRESS ANY KEY TO PROCEED ..."); getch(); setfillstyle(1,0); floodfill(5,300,rec); setcolor(0); rectangle(0,135,230,390); setcolor(rec); ShowMouse(); return ; } void winner() { HideMouse(); setcolor(rec); rectangle(0,135,230,390); setcolor(colorfortext); outtextxy(5,150,"welcome to ComputerLudo"); if(flagturn==0) { outtextxy(5,160,"CONGRATULATIONS"); outtextxy(5,170,"YOU WON THIS ROUND "); outtextxy(5,180,"OF"); outtextxy(5,190,"ComputerLudo"); outtextxy(5,210,"akshay thanks "); outtextxy(5,220,"you for trying this"); outtextxy(5,230,"game."); outtextxy(5,240,"thanks again."); outtextxy(5,310,"PRESS ANY KEY TO EXIT.."); } else { switch(flagturn) { case 1: {outtextxy(5,160,"COMPUTER1 WON THIS");break;} case 2: {outtextxy(5,160,"COMPUTER2 WON THIS");break;} case 3: {outtextxy(5,160,"COMPUTER3 WON THIS");break;} } outtextxy(5,170,"ROUND OF"); outtextxy(5,180,"ComputerLudo"); outtextxy(5,200,"BETTER LUCK NEXT TIME"); outtextxy(5,220,"akshay thanks "); outtextxy(5,230,"you for trying this"); outtextxy(5,240,"game."); outtextxy(5,250,"thanks again."); outtextxy(5,310,"PRESS ANY KEY TO EXIT.."); } getch(); exit(0); } void howtoplay() { HideMouse(); setcolor(rec); rectangle(0,135,230,390); setcolor(colorfortext); outtextxy(5,150,"This is a game between"); outtextxy(5,160,"COMPUTER and the PLAYER."); outtextxy(5,170,"Choose HOUSE by "); outtextxy(5,180,"clicking over the HOUSE of"); outtextxy(5,190,"your fovourite color."); outtextxy(5,200,"Get 6 on Dice to take a ludo"); outtextxy(5,210,"out of HOUSE.To make a ludo"); outtextxy(5,220,"MOVE click on it."); outtextxy(5,230,"CUT(send to house) computers"); outtextxy(5,240,"ludos by placing your ludos "); outtextxy(5,250,"over its ludos."); outtextxy(5,260,"One who gets all the ludos"); outtextxy(5,270,"HOME wins thE Game."); outtextxy(5,290,"FOLLOW THE MESSAGE BOX"); outtextxy(5,300,"GIVEN AT BOTTOM"); outtextxy(5,320,"thanks"); outtextxy(2,330,"Akshay."); outtextxy(5,350,"PRESS ANY KEY TO PROCEED ..."); getch(); setfillstyle(1,0); floodfill(5,300,rec); setcolor(0); rectangle(0,135,230,390); setcolor(rec); ShowMouse(); return ; }

  • C languagePreeti Tyagi January 23, 2012 at 8:28 PM

    Compiler TurboC cannot run effeciently TurboC++ programs but TurboC++ can?

  • programminggeneveve January 29, 2012 at 11:13 PM

    using loop & condition create a program that will display population forecast for five years showing 5% increase each year?

  • x^xpaul h February 6, 2012 at 9:03 PM

    Using <cmath> function pow(x,x), evaluate x^x in steps of 0.2 starting from x = -1 to x =+1.

  • C++ ProgramingSalajdin January 19, 2013 at 7:22 PM

    Number of Numbers over Average You are given a series of numbers, show the number of numbers which are greater than the average. Input specification The first number is the number of numbers (n) in the series where 1 < n < 100.000. Then you will be given n integer numbers where each of the is between -10.000 and 10.000. Output specification Just give one number which shows the number of numbers which are greater than the average of the series. Sample Input I: 5 1 2 3 4 5 Sample Output I: 2 Can someone help me for designing this program

  • C++ program did not understoodJitender February 17, 2012 at 11:30 PM

    /*can you explain this program to find GCD and LCM of two numbers*/ #include<iostream.h> #include<conio.h> int gcd(int m,int n) {while(m!=n) {if(m>n) m=m-n; else n=n-m; } return m; } int lcm(int m,int n) { return m*n/gcd(m,n); } void main() { int gcd(int,int); int lcm(int,int); int x,y; clrscr(); cout<<"enter two numbers"; cin>>x>>y; cout<<"GCD:"<<gcd(x,y); cout<<endl<<"LCM:"<<lcm(x,y); getch(); }

  • programmingdonties February 22, 2012 at 7:20 PM

    Can someone help me on the following programs in c++. 1.How to Write a function that accepts an array of non-negative integers and returns the second largest integer in the array. Return -1 if there is no second largest 2.Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X - Y 3. Write a function that accepts a character array, a zero-based start position and a length. It should return a character array containing containing length characters starting with the start character of the input array. The function should do error checking on the start position and the length and return null if the either value is not legal. Thank i really appreciate in advance.

  • crajsekhar vyas February 24, 2012 at 5:02 PM

    how to find the sum of a five digit number

  • question related to menu driven programmeanurag February 24, 2012 at 7:15 PM

    write a menu driven programme for the following options: 1)to find sum of odd no present in a 1d array of integers 2)to count multiples of 7 in a 1d array of integers 3)exit

  • C programmingShanna March 3, 2012 at 5:17 AM

    Hi! Below is my code for part of my program. I'm just starting in C and my teacher wants us to: "prompt the user for an integer n that calculates the nth Fibonacci number from main(). Pass the input value to the function fibonacci(n) that returns the value. Display the value to the console." So. My problem. This program works and displays the 6th number(for example) as 5, but only if I don't try to read in a value from a user. It only works if I assign 6 to n. If I try to prompt and scanf the input value, I get a ridiculously long negative value. EOF? And why??? What can I do to get it working correctly while reading in a number? #include <stdio.h> int fibonacci(int number); int main(void) { int n; int result; printf("Enter an integer: "); scanf("%d", &n); result = fibonacci(n); printf("The %dth Fib num is: %d\n", n, result); return 0; } int fibonacci(int number) { int a = 0; int b = 0; int sum; int counter; for(counter == 0; counter < number; counter++) { sum = a +b; a = b; b = sum; if(counter == 0){ b++; } else if(counter == 1){ b--; } else if(counter == 2) { a++; } } return sum; }

  • questionvasantha March 21, 2012 at 4:10 PM

    A set of number is given. The set contain odd numbers as well as even number. It is required to find the ratio total of even members to the total of odd numbers.

  • C++ programmingMokone Piet March 29, 2012 at 12:19 PM

    I need assistance on c++

  • i need to scan multiple variables given by userseler March 30, 2012 at 12:34 AM

    i have a university project and i need to make a code which in the begging will ask the user to enter his fistname, last name and his company's name. the only thing i've learned is the following. of course i first type: char first; char ...... . . printf("Give first name, last name and company's name: "); scanf("%c" "%c" "%c",&first,&last,&comp); the thing is that if i run it and give 3 words separated with a space, it crushes and prints everything else and quits. if i just type one word everything works fine. is there any way to make it work? or i'll have to create 3 different sets of printf-scanf?

  • engineering 197Jeremy April 21, 2012 at 9:10 PM

    M T W T F S S 1 | 10, 5, 7, 4, 9, 8, 11 2 | 9, 12, 8, 6, 10, 5, 10 3 | 8, 5, 10, 7, 9, 3, 12 4 | 11, 9, 13, 4, 8, 9, 9 5 | 9, 6, 9, 6, 7, 7, 8 6 | 10, 5, 10, 4, 8, 6, 12 7 | 12, 8, 7, 5, 6, 6, 10 8 | 10, 10, 9, 8, 9, 8, 13 Write a program that will print power consumption on Thursdays for the 8 weeks as shown on the example below: Week 1: 4MW Week 2: 6MW Week 3: 7MW ..... Week 8: 8MW I need help on how to write the program so it gives me 'thursdays' outputs. all i get is errors. any help would be great, Thanks

  • Variable usageBeginner April 11, 2012 at 11:59 PM

    Hi all, I have some doubt. I have to use a variable in a class that is at 4th level of execution,so do i use global variable or keep on passing the variable to the destination class ?? Any response will be appreciated.... Thanks.

  • computer progmannat April 12, 2012 at 12:35 AM

    the user to input a integer it should count the no of odd,even and zero for eg user enter 12345

  • how to assign last struct pointer value NULLshuddhasattwa paul April 13, 2012 at 2:08 PM

    Given below is my code: typedef struct coordinates { float x; float y; struct coordinates *next; } point; int main(void) { point *pt = malloc(sizeof(point)); point *head; head = pt; turn val; int i; float offset, offset1;`enter code here` int k = 0; for (i = 0; i < 5; i ++) { printf ("\n--for loop %d started--\n", i+1); scanf ("%f", & (pt->x)); scanf ("%f", & (pt->y)); pt = pt->next = malloc(sizeof(point)); printf ("\n--for loop %d ended--\n", i+1); } pt = head; while(pt != NULL) { printf("\n%f %f %u %u\n", pt->x, pt->y, pt, pt->next); pt=pt->next;} } this while loop runs forever because there is no pointer pointing to NULL. My problem is that I can not find any way of NULL value to pointer next of last structure element. Please help. I need a solution asap as I am going to implement linked list in some project. Thank You.

  • while loop helpJake April 14, 2012 at 5:16 AM

    Im trying to have this give a single output instead of having to keep pressing enter any help would be aprieciated heres what I have- #include <iostream> using namespace std; int main() { int rangeOne = 0; int rangeTwo = 0; int rangeThree = 0; int rangeFour = 0; int rangeFive = 0; int rangeSix = 0; int rangeSeven = 0; int rangeEight = 0; int score, students; int counter = 0; cout << "enter the number of students" << endl; cin >> students; cout << "enter " << students << " test scores" << endl; while(counter < students) { cin >> score; counter++; if (score <= 24) { rangeOne++; } else if (score >= 24 && score <= 50) { rangeTwo++; } else if (score >= 49 && score <= 75) { rangeThree++; } else if (score >= 74 && score <= 100) { rangeFour++; } else if (score >= 99 && score <= 125) { rangeFive++; } else if (score >= 124 && score <= 150) { rangeSix++; } else if (score >= 149 && score <= 175) { rangeSeven++; } else if (score >= 174 && score <= 200) { rangeEight++; } else { cout << "invalid range read..." << endl; } // output cout << "0 - 24: " << rangeOne << endl; cout << "25 - 49: " << rangeTwo << endl; cout << "50 - 74: " << rangeThree << endl; cout << "75 - 99: " << rangeFour << endl; cout << "100 - 124: " << rangeFive << endl; cout << "125 - 149: " << rangeSix << endl; cout << "150 - 174: " << rangeSeven << endl; cout << "175 - 200: " << rangeEight << endl; } system("PAUSE"); return EXIT_SUCCESS; }

  • Data Structure stacknoorah April 14, 2012 at 6:54 PM

    Write a C++ program that asks the user to enter an integer n followed by n numbers. The program will use 2 stacks to enter the numbers entered by the user. In every iteration the program will balance the total of the numbers stored in every stack. For example, if the user already entered 10 (the program stores this value in stack 1) and 23.5 (the program stores this value in stack 2) and then enters the value 4.7 then the program will store this value in stack 1 since 10<23.5. If the user enters 12.3, then the program will store it in stack 1 since the total in stack 1 is 14.7 (10+4.7) and 14.7<23.5. If the user enter 7, then the program will store this value in stack 2 since the total in stack 1 is 27 (14.7+12.3) and 27>23.5. At the end, the program will display on the screen the content of every stack.

  • MCSAdil Shafiq April 24, 2012 at 3:24 PM

    I am MCS Student.What way i adopt to get sharpness in programming.my recent degree bachlor of science with Math & Physics.

  • use a variable of my void fuction in my maineva April 28, 2012 at 7:06 PM

    Hi, I am new to c++ and have a question. In my code I need to use a variable of my void fuction in my main. A simple example is Void sendvariable (int x) { Int x=2 â?¦ } Int main () { â?¦.. Want to get x from above function and do something on it }

  • C++ksdjk May 7, 2012 at 10:14 AM

    The project is to use programming to solve everyday problem of travel, distance and proximity. The project is to produce a C++ program that reads input files to produce the difference and relativity of locations from a given starting point (ECC). Difficulty: Challenging Instructions Things You'll Need ? Location properties files: the first member of list in the file is the starting point ? Using the ECC (ECC.txt file) as the starting point; ECC file contains the following content: ECC 0 0 0 0 FarmersBestBank 0 135 0 0 Dante_s_Peak 0 0 0 285 Centurion_Hwy 320 50 0 0 Blockbuster 30 0 0 370 NiagraGiftStore 0 55 90 0 Warrens 0 0 85 100 Pavilion 135 0 0 0 OrionsCircle 75 45 0 0 WesternViewMMA 0 0 60 180 ShoppersOrganized 0 0 380 0 Format: LOCATION NORTH EAST SOUTH WEST Sample: Blockbuster 30 0 0 370 ? Blockbuster has distance of 30 North and 370 West of ECC; since ECC is the starting point indicated by the value of zero (0) in all directions. Distances are given in clockwise direction starting from North, then East, then South and finally West. ? ECC is the starting point hence the distance value of zero. 1. Output to a file ({STUDENTID}_TOTAL_DISTANCE.txt) using a scale of 5:1 character-line representing the total distances to the different locations from ECC is ascending order (i.e. from nearest to farthest location from ECC) i. Example LOCATIONS TOT CHARACTER LINE REPRESENTATION OrionsCircle 120 ************************ FarmersBestBank 135 *************************** Pavilion 135 *************************** NiagraGiftStore 145 ***************************** Warrens 185 ********************************* WesternViewMMA 240 ************************************************ Dante_s_Peak 285 ********************************************************* Centurion_Hwy 370 ************************************************************************** ShoppersOrganized 380 ****************************************************************************** Blockbuster 400 ******************************************************************************** Clockwise CIS121-100 Class Project FALL 2011 Page 2 of 3 Instructor: Okaey Ukachukwu 2. output to a file ({STUDENTID}_DIRECTION_DISTANCE.txt) using a scale of 5:1 character-line representing the distances and directions to the different locations from ECC is ascending order or total distance(i.e. from nearest to farthest location from ECC) i. Example 2a LOCATIONS TOT NORTH EAST SOUTH WEST OrionsCircle 120 *************** ********* 0 0 FarmersBestBank 135 0 *************************** 0 0 Pavilion 135 *************************** 0 0 0 NiagraGiftStore 145 0 *********** ****************** 0 Warrens 185 0 0 ***************** ******************** WesternViewMMA 240 0 0 ************ ************************************ Dante_s_Peak 285 0 0 0 ********************************************************* Centurion_Hwy 370 **************************************************************** ********** 0 0 ShoppersOrganized 380 0 0 ****************************************************************************** 0 Blockbuster 400 ****** 0 0 **************************************************************************** OR ii. Example 2b LOCATIONS TOT DISTANCE DIRECTION OrionsCircle 120 ********** * * * * * * * * * * * * S FarmersBestBank 135 S*************************** Pavilion 135 * * * * * * * * * * * * * * * * * * * * CIS121-100 Class Project FALL 2011 Page 3 of 3 Instructor: Okaey Ukachukwu * * * * * * * S NiagraGiftStore 145 S************ * * * * * * * * * * * * * * * * * … etc … … … REMEMBER TO: Output the results to file and submit program with output result files. 3. Output to a file the total distance and direction of the locations from ECC LOCATIONS TOTAL DISTANCE DIRECTION FROM ECC FarmersBestBank 135 EAST OR E Dante_s_Peak 285 WEST OR W Centurion_Hwy 370 NORTHEAST OR NE Blockbuster 400 NORTHWEST OR NW NiagraGiftStore 145 SOUTHEAST OR SE Warrens 185 SOUTHWEST OR SW Pavilion 135 NORTH OR N OrionsCircle 120 NORTHEAST OR NE WesternViewMMA 240 SOUTHWEST OR SW ShoppersOrganized 380 SOUTH OR S 4. Repeat these steps for the other destination files Tips & Warnings ? All the distances are integers Resources Class Notes & Textbook

  • C++ksdjk May 7, 2012 at 10:17 AM

    The project is to use programming to solve everyday problem of travel, distance and proximity. The project is to produce a C++ program that reads input files to produce the difference and relativity of locations from a given starting point (ECC). Difficulty: Challenging Instructions Things You'll Need ? Location properties files: the first member of list in the file is the starting point ? Using the ECC (ECC.txt file) as the starting point; ECC file contains the following content: ECC 0 0 0 0 FarmersBestBank 0 135 0 0 Dante_s_Peak 0 0 0 285 Centurion_Hwy 320 50 0 0 Blockbuster 30 0 0 370 NiagraGiftStore 0 55 90 0 Warrens 0 0 85 100 Pavilion 135 0 0 0 OrionsCircle 75 45 0 0 WesternViewMMA 0 0 60 180 ShoppersOrganized 0 0 380 0 Format: LOCATION NORTH EAST SOUTH WEST Sample: Blockbuster 30 0 0 370 ? Blockbuster has distance of 30 North and 370 West of ECC; since ECC is the starting point indicated by the value of zero (0) in all directions. Distances are given in clockwise direction starting from North, then East, then South and finally West. ? ECC is the starting point hence the distance value of zero. 1. Output to a file ({STUDENTID}_TOTAL_DISTANCE.txt) using a scale of 5:1 character-line representing the total distances to the different locations from ECC is ascending order (i.e. from nearest to farthest location from ECC) i. Example LOCATIONS TOT CHARACTER LINE REPRESENTATION OrionsCircle 120 ************************ FarmersBestBank 135 *************************** Pavilion 135 *************************** NiagraGiftStore 145 ***************************** Warrens 185 ********************************* WesternViewMMA 240 ************************************************ Dante_s_Peak 285 ********************************************************* Centurion_Hwy 370 ************************************************************************** ShoppersOrganized 380 ****************************************************************************** Blockbuster 400 ******************************************************************************** Clockwise CIS121-100 Class Project FALL 2011 Page 2 of 3 Instructor: Okaey Ukachukwu 2. output to a file ({STUDENTID}_DIRECTION_DISTANCE.txt) using a scale of 5:1 character-line representing the distances and directions to the different locations from ECC is ascending order or total distance(i.e. from nearest to farthest location from ECC) i. Example 2a LOCATIONS TOT NORTH EAST SOUTH WEST OrionsCircle 120 *************** ********* 0 0 FarmersBestBank 135 0 *************************** 0 0 Pavilion 135 *************************** 0 0 0 NiagraGiftStore 145 0 *********** ****************** 0 Warrens 185 0 0 ***************** ******************** WesternViewMMA 240 0 0 ************ ************************************ Dante_s_Peak 285 0 0 0 ********************************************************* Centurion_Hwy 370 **************************************************************** ********** 0 0 ShoppersOrganized 380 0 0 ****************************************************************************** 0 Blockbuster 400 ****** 0 0 **************************************************************************** OR ii. Example 2b LOCATIONS TOT DISTANCE DIRECTION OrionsCircle 120 ********** * * * * * * * * * * * * S FarmersBestBank 135 S*************************** Pavilion 135 * * * * * * * * * * * * * * * * * * * * CIS121-100 Class Project FALL 2011 Page 3 of 3 Instructor: Okaey Ukachukwu * * * * * * * S NiagraGiftStore 145 S************ * * * * * * * * * * * * * * * * * … etc … … … REMEMBER TO: Output the results to file and submit program with output result files. 3. Output to a file the total distance and direction of the locations from ECC LOCATIONS TOTAL DISTANCE DIRECTION FROM ECC FarmersBestBank 135 EAST OR E Dante_s_Peak 285 WEST OR W Centurion_Hwy 370 NORTHEAST OR NE Blockbuster 400 NORTHWEST OR NW NiagraGiftStore 145 SOUTHEAST OR SE Warrens 185 SOUTHWEST OR SW Pavilion 135 NORTH OR N OrionsCircle 120 NORTHEAST OR NE WesternViewMMA 240 SOUTHWEST OR SW ShoppersOrganized 380 SOUTH OR S 4. Repeat these steps for the other destination files Tips & Warnings ? All the distances are integers Resources Class Notes & Textbook

  • Send characters to ms wordHamid reza May 13, 2012 at 9:39 PM

    Hi all, I would wondering if someone could help me to tell how can i send characters from a textbox to an open ms word document. Is it possible to use of PostMessage? if yes, how ? Please help me, friends. thanks all,

  • merge sortJake May 20, 2012 at 9:47 AM

    Hi. Could anyone tell me why I cannot see any result from my merge sorting code? --------------------------------- #include <stdio.h> void merge(int* a, int low, int mid, int high) { int left_head = low; int left_tail = mid; int right_head = mid+1; int right_tail = high; int i = 0; int temp[high-low+1]; while ((left_head<=left_tail)&&(right_head<=right_tail)) { if (a[left_head] < a[right_head]) { temp[i++] = a[left_head++]; } else { temp[i++] = a[right_head++]; } } while (left_head<=left_tail) { temp[i++] = a[left_head++]; } while (right_head<=right_tail) { temp[i++] = a[right_head++]; } for (i=0; i<high-low+1; i++) a[i] = temp[i]; } void merge_sort(int* a, int low, int high) { int mid; printf("%d,%d", low, mid); if (low<high) { mid = (int)(low + high)/2; printf("left %d,%d", low, mid); merge_sort(a, low, mid); printf("left %d,%d", mid, high); merge_sort(a, mid, high); merge(a, low, mid, high); } } int main() { int i; int b[] = {1,10,8,-3}; for (i=0; i<4; i++) printf("%d,",b[i]); merge_sort(b, 0, 3); for (i=0; i<4; i++) printf("%d,",b[i]); return 0; }

  • knowledgemuhizi May 22, 2012 at 2:36 PM

    i want to know

  • Usage of For LoopPrince Allen Noel June 4, 2012 at 6:00 PM

    I have a doubt which way is correct in using the for loop. I dont understand whether which is the correct usage between these 2 loops for(i=0;i<5;i++) and for(i=1;i<=4;i++). Please help me out.

  • error in coding, gives only Fail or first divisionfayaz June 16, 2012 at 8:59 AM

    Dear sir, I am a novice, trying to self learn c language. when put the following code for 5 subjects percentage. It gives the output either Fail or First Division, what so ever the input marks i put in, please check it and correct me. thanks Method 1. /* Method I */ #include<stdio.h> int main () { int m1,m2,m3,m4,m5,per; printf("Enter marks in five subjects"); scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5); per=(m1+m2+m3+m4+m5)/500*100; if(per>=60) printf("First Divison\n"); else { if(per>=50) printf("Second Divison\n"); else { if(per>=40) printf("Third Divison\n"); else printf("Fail\n"); } } return 0; } Method 2 /* Method II */ #include<stdio.h> int main() { int m1,m2,m3,m4,m5,per; printf("Enter marks in five subjects"); scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5); per=(m1+m2+m3+m4+m5)/500*100; if(per>=60) printf("First Division\n"); if((per>=50)&&(per<60)) printf("Second Division\n"); if((per>=40)&&(per<50)) printf("Third Division\n"); if(per<40) printf("Fail\n"); return 0; }

  • polymorphismanilpetkar June 20, 2012 at 11:01 PM

    why do we require polymorphism? because we need to override virtual function in remaining classes and we need access through pointer for function. instead we can create same function in different class and we can access that class using objective of respected class.then compiler will function from which class.

  • Programmingajay June 25, 2012 at 8:29 AM

    How to create a program that accepts a set of integers and finds the number of positive and negative value?

  • array of numbers into integer valuerajiv June 27, 2012 at 12:01 PM

    Hi, There is one array let say a[] and user entered some elements, i need to convert this array of numbers into integer value. Ex:- a[i] = { 2,3,4,5}; i need this array as n=2345 as a single number. Pls mail me if anyone knws how to do it.

  • c programram June 29, 2012 at 4:05 PM

    how to get out put as 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6

  • give code for this problm asap prakhar July 4, 2012 at 11:58 AM

    ================================================================= [[ A SIMPLE LANGUAGE OF EXPRESSIONS ] In this lab you have to write an evaluator for a simple language of expressions. The language has variables, integer constants, simple binary expressions (var1 OP var2) and following type of statements: 1. Constant assignment: var = integer_constant EX: v1 = 5 2. Binary expression assignment: var = var1 OP var2 where OP is one of + - * / % EX: v1 = a + b 3. Evaluate Stmt: eval var It evaluates the expression defining var and prints it. Note that a var could be undefined . EX1: v1 = 5 v2 = v1 + v3 v3 = 7 eval v2 => 12 NOTE : It is possible to "use" a variable before "definition". The definition should be available before the "eval" takes place, as in the above example. EX2: v1 = 5 v2 = v1 + v3 eval v1 => 5 eval v2 Error: Undefined Variable v3 4. List all variable bindings: list Prints all variables and their values currently in the store. EX: v1 = 5 v2 = v1 + v3 v3 = 7 list -------------------------x------------------------- VARIABLE| VALUE -------------------------x------------------------- v1| 5 v2| 12 v3| 7 -------------------------x------------------------- 5. Stop the program: halt EX: halt => Good Bye Some sample interactions with the system: //////////// SAMPLE INTERACTION #1 //////////////////////////// $ ./a.out a = 71 b = 22 c = a / b d = a % c e = a + d f = g + h g = 55 h = 22 u = g - h eval g => 55 eval h => 22 eval a => 71 eval b => 22 eval d => 2 list -------------------------x------------------------- VARIABLE| VALUE -------------------------x------------------------- a| 71 b| 22 c| 3 d| 2 e| 73 f| 77 g| 55 h| 22 u| 33 -------------------------x------------------------- halt => Good Bye //////////// SAMPLE INTERACTION #2 //////////////// $ ./a.out a = 7 b = -9 c = b - a d = b * a eval d => -63 eval c => -16 e = -1 f = e * d eval f => 63 halt => Good Bye //////////// SAMPLE INTERACTION #3 /////////////// $ ./a.out a = 5 a = 7 Error: Duplicate definition for a //// END OF SAMPLE INTERACTIONS/////////////////// As you can see, multiple definitions for a variable are NOT allowed. Also note that, because the definition of a variable can come after its use, you CAN NOT evaluate the expression on right hand side of an assignment immediately after reading the statement. The expression must be evaluated only when you encounter "eval" or "list" command. You have to write a C program to read the statements from the input, and store the variable-value (as expression) bindings, or perform the action requested. Use "struct"(structures) and "unions" in C to design an appropriate storage for a variable and its value. Use a linked list of variables to store all variables. USE OF ARRAYS IS NOT PERMITTED for this. Simplifications/Enhancements: 1. You will find it easier to handle only POSITIVE constants first. Later extend it to negative constants (for extra marks). 2. Use memoization to remember the value of a variable first time it is evaluated, and reuse it if the value is required again (again bonus marks).

  • c program codeRamel July 11, 2012 at 12:52 PM

    i have made a simple quiz program source code, but i have a problem regarding for the computation of the scores, what should i do to compute the scores.?

  • loopscesar July 13, 2012 at 6:28 PM

    Hi everyone, I am a beginner in c++ programming, basically i am working on root that is based on c++. I have the following list: i evt_no chi2 1 1200 0.015 2 1200 1.36 3 1200 0.0054 4 1200 3.69 5 1320 1.005 6 1547 0.85 7 1547 7.698 8 1547 1.478 . . . and so on... basically I want to select the evt_no with the minimum chi2 but I have no clue how to proceed. the programm goes as Float_t evt_no, chi2; the_tree->SetBranchAddress("evt_no",&evt_no); the_tree->SetBranchAddress("chi2",&chi2); for(Int_t j = 0; j < the_tree->GetEntries(); j++){ the_tree->GetEntry(j); Float_t chi2_min=10000; if(evt_no){ if(chi2<chi2_min) chi2_min=chi2; evt_no ++; } cout<<"i: "<<i<<" evt_no: "<<evt_no<<" chi2: "<<chi2<<"chi2_min: "<<chi2_min<<endl; } The algorithm that I was trying to implement is while the evt_no does not change loop over all evt_no and find the one with the minimum chi2, once this is done move to the next evt_no and do the same procedure, until for each event I find the min chi2. But I do not know how to translate this in c++ language...any help/suggestion would be very welcome, thanks in advance, Cesar

  • C++Ian Woodgate July 16, 2012 at 8:06 AM

    Hi. My program was to allow 5 numbers to be input and find the sum of the five numbers. If the sum was equal to zero to display the numbers in the order they were submitted. If the sum of the five numbers were a positive or negative number they were to be display in ascenting and desending order respectively. Oh and you can't use arrays. I got most of it working using lots of if statements but the displays would be 0 0 0 0 0 instead of the actual numbers. If you could help that would be great. Thanks Ian

  • Dynamic single linked list(c++)Bassam July 23, 2012 at 5:10 AM

    1- write a program to copy the content of the following array to a dynamic single linked list, and write a function to delete every node has an even value in its data ? #include <iostream> using namespace std; //struct struct list { int data ; list *next ; }; void del_Ev(list *&head, list *&tail) { list *l_tail, *node ; int found = 0 ; node = tail ; while(tail) { if(tail->data % 2 == 0) found = 1 ; else { l_tail = tail ; tail = tail->next ; } if(found) { if(node == tail) { head = head->next ; delete node; } else { l_tail->next = tail->next ; node = tail ; tail = tail->next ; delete node ; } } } } int main() { list *node = NULL, *tail = NULL, *head = NULL; int a[] = {1, 4, 6, 3, 7, 11, 8, 9, 10}; for (int i = 0; i < 9; i++) { node = new list; // create new node ... node->data = a[i]; //set a[i] value to date element in newnode structure node->next = NULL; //set next to null to be end of node ... if (head == NULL) { head = node; tail = node; //set tail to piont to end of list .. } else { tail->next = node; tail = node; } } tail = head ; del_Ev(head, tail); // before deleting %2 = 0; cout << " before deleting %2 = 0" << endl; list *tmp = new list; tmp = head; while (tmp) { cout << tmp->data << " "; tmp = tmp->next; } return 0; } the program doesn't work well with me plz help me :)

  • ITChivorn July 26, 2012 at 8:13 PM

    If i want to write that "if(ch=='\0')" (ch is 1 char) it wrong or rigth, if wrong tell me?

  • Increment and decrement operatorAbhishek barman July 28, 2012 at 5:45 PM

    I am having problem in using this operator ex. int c,n;n=10; c=(--n - n-- - --n); cout<<c; } The value of this exprssn in java is -7. And in c++ is -8. So there is a difference in the answer i am in class xi and i am facing problem with this in c++ could you explain it briefly.

  • c algo or programshashank August 1, 2012 at 11:32 AM

    how to print 1 2 3 3 1 2 2 3 1 and [4,-6,-2,5,-3] [-6,-3,-2,4,5]

  • Kindly provide source codeAnuarg August 7, 2012 at 12:04 AM

    I have generated Fibbonacci series and i want to search any number in this series. How will this be done.Please send source code

  • Doubtlokesh ponnada August 8, 2012 at 11:25 AM

    Dear sir , i have written a program on selection sort. the entire thing when i check is correct and it is also compiling. The problm is that whenever it is executed it is giving the size of the array infinitely..plz help.. PROGRAM #include<stdio.h> void selectsort(int a[],int size,int k) { int i=k; int j,mval,p; for(i=k;i=size-1;i++) { mval = a[i]; for(j=i+1;j<size;j++) { if(a[j] < mval){ p=a[j]; a[j]=mval; mval=p; } } a[i]=mval; printf("%d",a[i]); } } int main(){ int b[4]={2,7,8,4}; selectsort(b,4,0); return 0; }

  • oopssachin August 21, 2012 at 8:31 PM

    asking questions about oops

  • qwestion about c++vishal August 21, 2012 at 9:09 PM

    Q.write a program to asked the user for a number. the program that print a line indicating that the number is greater than 0 or that is not.

  • c programingtapiwa morgan August 24, 2012 at 5:17 PM

    help me guyz

  • Mind blowing bugSam August 24, 2012 at 11:36 PM

    Hello, I'm programing for about a year now ( but not on C ) and i'm trying to get use to pointer in C, so i'm doing a little exercice. BUT I have a problem with "scanf" function here is my code : #include <stdlib.h> #include <stdio.h> typedef struct node { int n ; struct node *next; } node; main() { int tmpchoice = 10; int val,i,choice; node *first = NULL; node *tmp = NULL; const int SIZE = sizeof(node); do { printf( " --MENU-- \n\n 1- Display\n 2- Insert (at the end)\n 3- Find\n 4- Delete any occurrence\n 5- Sort\n 6- Insert in sorted list\n 0- Exit\n\n"); scanf("%d", &tmpchoice); choice=(int) tmpchoice; printf("\n"); tmp=first; /* then there is a switch which is sertenly not the problem. I commented it and it still doesn't word */ } while(choice != 0); Well "scanf" dicided not to get executed after the first time when I enter a CHAR instead of an INT and it causes an infinit loop. Does ANYONE know what is the problem ?

  • Data DecodingAnthony August 26, 2012 at 5:28 PM

    Hi, I am having trouble with a school project and need assistance. Basically, i need to create a program which reads an input text file and produces another text file as an output. The names of these files are given as command line arguments. The output needs to use integers as ASCII characters. The input file (SampleData.txt) contains the following sets of numbers: 757935403 544999979 175906848 538976380 757795452 170601773 170601727 The output file (Result.txt) must display the following ASCII art picture: +---+ | | | | +---+ Your assistance would be much appreciated! Thanks, Anthony

  • C++ programmingshalenee August 28, 2012 at 10:51 AM

    (finding numbers divisible by 5 and 6 using loops in C++) write a program that displays, ten numbers per line, all the numbers from 100 to 1000 that are divisible by 5 and 6.

  • Urgent C program help plz Fady December 26, 2012 at 7:48 PM

    I have done my researches and still un-able to solve this program so please I need someone to help me or even solve it but as I think we must use semaphores, forks and pipes that's what I think but no nothing else about it.can anyone solve it plz ? am not good in C language... thanks for all. We are requested to implement a code cracking system. The system will deploy four processes (p1,p2,p3 & p4) to try to guess the password of an encrypted code. For encryption, we consider that the formula is: C = P XOR K, where â?¢ C = encrypted code â?¢ P = plain text â?¢ K = key For decryption the formula is: P = C XOR K. So, your program will try to find K using this formula. The XOR operator is ^. Given an encrypted code C and plain code P your program should deploy three processes to try and find the key used to encrypt the plain code. These three processes will be under the control of process P1. All processes will send their results to process P1 and process P1 will terminate the three processes and display the encryption key and decrypted text once any of the three processes finds the key. For simplicity we will consider that we have the original number P stored in a file called plain.txt and the encrypted code is stored in a file called cipher.txt. Consider that only numbers are stored in these files and they have a range between 0 and 100000000. So we have P and C your program should find the key K. Consider that K is a positive number between 0 and 1000000.

  • Wrong Output.....NOt predicted oneArun Sharma August 31, 2012 at 3:26 PM

    hie everyone.......heres a sample of source code #include <iostream.h> #include <conio.h> #include <math.h> int main() { int i=2,a; a= pow(10,i); int b=0; b+=a; cout<<b; getch(); } the o/p that i expect is 100 as clear. BUt the compiler give 99 as o/p. Can anyone please explain whats the problem in the code...and how it can b corrected to get"100" as o/p. THanx.

  • c programejagdish.mourua September 3, 2012 at 8:19 PM

    always help everyone God always help you

  • c programminglikitha September 6, 2012 at 6:48 PM

    main() { int i=43; printf("%d",printf("%d,printf("%d",i))); }

  • c programminglikitha September 6, 2012 at 6:52 PM

    main() { int i=300,j=400; printf("%d...%d"); }

  • c programminglikitha September 6, 2012 at 6:54 PM

    main() { char *ptr="hello"; strcpy(ptr,ptr+1); printf("%s",ptr); }

  • C++ ProgrammingMaurice Mason September 9, 2012 at 12:14 AM

    I have a programm question can you solve it for me and write the code for me

  • cRam September 13, 2012 at 7:48 PM

    How to pass return pointers?

  • using one function for multiple purposeGaurav chand September 17, 2012 at 11:02 PM

    //sir i want to show u this program please have a look at //it. //this program shows use of a simple function sum() with //different values types(such as float,int) #include<iostream.h> int sum(int ,int); float sum(int ,float); float sum(float ,float); void main() {int a,b,s,ch; float p,q,z; cout<<"please enter choice\n1.int+int\n2.int+float\n3.float+float"; cin>>ch; if(ch==1) {cout<<"enter two no int"; cin>>a>>b; s=sum(a,b); cout<<a<<"+"<<b<<"="<<s; } if(ch==2) {cout<<"enter one float one int"; cin>>a>>q; z=sum(a,q); cout<<a<<"+"<<q<<"="<<z; } if(ch==3) {cout<<"enter two no float"; cin>>p>>q; z=sum(p,q); cout<<x<<"+"<<y<<"="<<z; } getch(); } int sum(int x,int y) {int s=x+y; } float sum(int x,int y) {float s=x+y; } float sum(int x,int y) {float s=x+y; } /*i wish to ask that when i input choice as 1 and input 1 float value it takes only float value and displays result as float value+0=float value eg :- output please enter choice 1.int+int 2.int+float 3.float+float 1 enter two no int 1.1 1.1+0=1.1 sir i wished to ask if why this output is coming please help me anyone if u can .i know it is because of using float value instead of int but i wish to ask why it is happening

  • C LangyageNarendra Mathuriya September 23, 2012 at 6:25 PM

    what will be the output of the following code #include<stdio.h> void main() { int m=2; printf("%d %d %d", ++m, ++m, ++m); } in turbo C it gives 432 but in other compilers it givses 222 so what will be the final answer

  • c languagenarendra mathuriya September 23, 2012 at 6:27 PM

    what will be the output of the following code #include<stdio.h> void main() { int m=2; printf("%d %d %d", ++m, ++m, ++m); } in turbo C it gives 432 but in other compilers it givses 222 so what will be the final answer

  • programingahsan December 15, 2012 at 1:51 PM

    sir how i creat regression graph in c++. i will this code witin 2 days

  • CplusplusFuji Daichi December 15, 2012 at 2:42 PM

    please help me!! i am newbie in Cplusplus... Question Addition, Subtraction and Multiplication Your program can be used as a math tutor for a young student. The program should display two random numbers between 1 and 9. After the student has entered an answer, the program should display the correct answer so the student can see if his/her answer is correct.

  • cmamta September 25, 2012 at 9:25 PM

    if we take a five digit no then what is the program to calculate the sum of its digit

  • C++Neeraj September 26, 2012 at 5:23 PM

    Sir i want to take screenshots of c++ graphics programs output. Please help me in this.

  • C++Nitin tyagi September 27, 2012 at 11:02 AM

    Just i have some question for discussion

  • c++roneey December 6, 2012 at 11:22 PM

    i want perpect answer

  • c++roneey December 6, 2012 at 11:24 PM

    i want perfect answer

  • programming c++sidra ahsaan December 7, 2012 at 1:54 AM

    between any two integers find all the numbers divisible by 5 and 10

  • c++ exerciseorabi December 7, 2012 at 5:09 AM

    1) Algorithm can be defined as _________________. (Choose one)) [1] a) A logical and concise list of steps required to solve a problem. b) A sequence of diagrams required to solve a problem. c) A concise list of steps required to solve a problem. 2) _________ is the process of following one of two or more alternate paths of computations. (Choose one) [1.5] a) Branching. c) Loops b) Instructions. d) Algorithms. 3) A program requires all the variables to be declared before they are used. (Choose one) [0.5] a) True. b) False. 4) Which one of the following loop is ideally used when we know how many times the loop will be executed ? [1] a) For. c) Repeat...until. b) While. 5) void main () The above line of the program indicates the _____________ of a program. (Choose one) [1] a) Stop. c) Start. b) End. d) Break 6) What will be the output of the following code segment? (Choose one) for(i=1; i<3; i++) { for(j=1; j<3; j++) { printf(â??%d â??, i*j); } } [2] a) 1 1 1 2. c) 1 2 2 4. b) 1 2 2 3. d) 1 2 2 2. 7) ______ statements can change the flow of program. (Choose one) [1] a) Logical. c) Unconditional. b) Conditional. d) Mathematical. 8) For calculating the average marks for 100 students, the step that calculates the average for one student has to be repeated _______ times, if the loop starts with a value of 0. (Choose one) [1] a) 99. c) 101. b) 10. d) 100. 9) void main( ) { putchar(â??zâ??); putchar(70); } What is the output of the above code? (Choose one) [1.5] a) zF. c) 90F. b) z70. d) 9070. 10) void main( ) { putchar ( 'n' ); } What is the output of the above code? (Choose one) [1] a)N b)â??nâ?? c)â??Nâ?? c)n 11) After accepting a character, the ________ function waits for the Enter key to be pressed. (Choose one) [1] a) getch(). c) putchar(). b) getchar(). d) putch(). 12) In a while loop, the condition is tested only after the body of the loop is executed at least once. [0.5] a) True. b) False. 13) What will be the output of the following expression? (Choose one) i =10; if(i> 5 * 4) printf(â??%dâ??, i) [1] a) None. c) 10. b) 1. d) 20. 14) The following expression will evaluate to _____________. (Choose one) (5+9*3^2-4 > 10) AND (2+2^4-8/4 > 6) OR (3<6 AND 10 >11)) [2] a) 4. c) 6. b) True. d) False. 15) If the first condition is false and the second condition is true, the result of the AND operator will be ______. (Choose one) [0.5] a) True. b) False. 16) The result of which arithmetic operator will return 81 (Choose one) [1] a) 9+2. c) 9^2. b) 9/2. d) 9*2. 17) What will be the output of the following code? (Choose one) int j; for(j=1; j<10; j+=2) printf(â??%d â??,j); [1] a) 1 2 3 4 5 6 7 8 9. c) 1 3 5 7 9. b) 2 4 6 8. d) 1 2 4 6 8. 18) What will be the value of *x? (Choose one) int a =20,b=50; int *x; x=&a; x=&b; [1] a) 20. c) a. b) 50. d) b. 19) The index of an array starts at one. (Choose one) [0.5] a) True. b) False . 20) The address operator is shown using the ________symbol (Choose one) [1.0] a) *. c) &. b) #. d) @. 21) A value of 20 is to be assigned to the third element of an array. Which is the right method? (Choose one) a) Num[3]=20. c) Num[4]=20. b) Num[2]=20. d) [4]num=20. 22) Identify the statement that produces the following output. (Choose one) 1 22 333 4444 55555 [2.0] a) for(a = 1; a <= 5; a = a + 1) { for( b = 1; b <= 5; b = b + 1) printf("%d", b); printf("\n"); } b) for( a = 1; a <= 5; a = a + 1) { for( b = 1; b <= a; b = b + 1) printf("%d", a); printf("\n"); } c) for( a = 1; a <= 5; a = a + 1) { for( b = a; b <= 5; b = b + 1) printf("%d", b); printf("\n"); } d) for( a = 1; a <= 5; a = a + 1) { for( b = 1; b < a; b = b + a) printf("%d", b); printf("\n"); } 23) A file pointer is essential for reading or writing files. (Choose one) [0.5] a) True. b) False . 24) Fp=fopen(â??c:\jak.txtâ??,â??Wâ??) in this Statement â??Wâ?? Stands for ? (Choose one) [2.0] a) Open a text file for reading c) Create a text file for writing b) Append to a text file d) None. 25) The function feof() returns true if the end of the file has been reached, otherwise it returns false (0). (Choose one) [1.0] a) True. b) False .

  • instantiated from here errorsomprakash jaiswal December 9, 2012 at 4:01 PM

    i have written a code for converting postfix expression into prefix. i am facing problem in executing this program.i get an error massage like "instantiated from here" in function pospre #include<iostream> #include<cctype> #include<cstring> using namespace std; const int size=20; template <class T> class stack { public: T a[20]; int top; int i; T p1;T p2;T p3; stack(); void pospre(T *b); void print(); void push(T y) { if(top==size-1) { cout<<"stack is full"; return; } else a[++top]=y; } T pop() { if(top==size-1) { cout<<"stack is full"; return 0; } else return(a[top--]); } }; template<class T> stack<T>::stack():top(-1),i(0) { } template<class T> void stack<T>::pospre(T *b) { while(b[i]!="\0") { if(b[i]=="/"|| b[i]=="*"||b[i]=="-"||b[i]=="+") { p1=pop(); p2=pop(); strcpy(p3,*b); strcat(p3,p2); strcat(p3,p1); push(p3); i++; } else { push(b[i]); i++; } } } template<class T> void stack<T>::print() { cout<<pop(); } int main() { stack<string> s; string c[20]={"a","b","+"}; s.pospre(c); s.print(); system("pause"); return 0; }

  • passing a string abhishek October 1, 2012 at 10:20 PM

    #include<stdio.h> #include<conio.h> void rev_str(char ch[]); int count_length(char ch[]); void main() { char str[10]; printf("enter the string\n"); scanf("%s",str); rev_str(str); printf("%s",str); getch(); } void rev_str(char ch[]) {int n,i; n=count_length(ch); for(i=0;i<n;i++){ ch[i]=ch[n-i];} } int count_length(char ch[]) { int i=0; char *chk=ch; while(*chk!='\0'){i++; chk++;} return(i);} why it is not working???

  • prime no. from 1 to 29 in reverse orderPukar December 10, 2012 at 9:38 PM

    #include<stdio.h> main() { int a,i,j,count=0; for(i=29;i>=1;i--) { for (j=2;j<i;j++) { a=i%j; if (a==0) {count=count+1; } } if(count==0) { printf("%d\t",i); } } }

  • csc103 c++noor December 11, 2012 at 1:48 PM

    Write a Value-Returning function factorial (n) with one parameter: - A value parameter n of type long - Return value of type long - The function factorial (n) find the factorial of a number (n!) . - Write a main function in which call the function factorial (n). For example, to obtain the factorial of a number (n!) the mathematical formula would be: n! = n * (n-1) * (n-2) * (n-3) ... * 1 more concretely, 5! (factorial of 5) would be: 5! = 5 * 4 * 3 * 2 * 1 = 120

  • want correct codealichishti October 3, 2012 at 2:02 PM

    I m in trouble with the following code... plz help.... I want 1.when i type wrong username or password it returns and if it is correct then it simpley goes to the mainMenu then calculatorMenu then basicCalcMenu and so on... but in this code after the mainMenu it returns to start up plz do something wid diz code. 2.the program is running but the menus are also not working as i want plz also help about it... 3.Also keep in mind dat i m a beginner not a professional //Thanks in anticipation..... #include <iostream> #include <string> #include <cstdlib> //system("cls"); exit(); #include <iomanip> // setw(); #include <cstdio> using namespace std; //Function Prototypes void mainMenu(int code); void calculatorMenu(int code); void basicCalcMenu(int code); int main() { string getinput; int code; int a, b, r; char option = 'Y'; startup: system("cls"); cout << "Type login to Start OR exit to Leave|..."; cin >> getinput; if(getinput == "login"){ system("cls");cout << "Username:"; cin >> getinput;} if(getinput == "nadir"){ cout << "Password:"; cin >> getinput;} if(getinput == "lucky"){ system("cls");mainMenu(code);} if(getinput == "exit"){ exit(0);} else{goto startup;} do { mainMenu(code); do { calculatorMenu(code); do { basicCalcMenu(code); if(code==1 || code==2 || code==3 || code==4 || code==5){ cout << "Enter First Number..."; cin >> a; cout << "Enter Second Number.."; cin >> b; switch(code){ case 1:r=a+b; break; case 2:r=a-b; break; case 3:r=a*b; break; case 4:r=a/b; break; case 5:r=a%b; break; case 0:exit(0); break; default:cout << "YOU TYPED WRONG"; } cout << "The Result is........" << r; } cout << "\nWould you like to repeat? (Y/N): " ; cin >> option; system("cls"); } while(toupper(code) == 'Y'); //This statement is attached with second do-while loop i.e calculatorMenu cout << "\nWould you like to return to calculator menu? (Y/N): " ; cin >> option; system("cls"); } while(toupper(option) =='Y'); //This statement is attached with first do-while loop i.e mainMenu cout << "\nWould you like to return to the main menu? (Y/N): " ; cin >> option; system("cls"); } while(toupper(option)=='Y'); }//End of main function //Function Definations void mainMenu(int code){ cout << " MAIN MENU\n =========\nCode ITEM\n1. CALCULATOR\n2. CONVERTOR\n3. EXIT\n"; cout << "Enter CODE|.."; cin >> code; system("cls"); } void calculatorMenu(int code){ cout << " CALCULATOR MENU\n ==============\nCode ITEM\n1. BASIC CALCULATOR\n2. ADVANCE CALCULATOR\n0. EXIT\n"; cout << "Enter CODE|.."; cin >> code; system("cls"); } void basicCalcMenu(int code){ cout << setw(42) << "BASIC CALCULATOR\n===============\nCode ITEM\n1. ADD\n2. SUBTRACT\n3. MULTIPLY\n4. DIVIDE\n5. REMAINDER\n0. EXIT\n"; cout << "Enter CODE|.."; cin >> code; system("cls"); }

  • C++ QuestionsAli Hamed Alalwi December 11, 2012 at 10:22 PM

    hello this is my questions Q1 . write a program that reads an integer and print it the horizontal order of the screen. Q2 . write a program that asks user to type 20 integer and write the number of occurrence of the largest value . Q3 . write a program to display the sum of the series 1+1/2+2/3+3/4+4â?¦â?¦â?¦â?¦â?¦â?¦â?¦+(n-1)/n ( using for loop ) Q4. Write a program that has two convert function to convert a give number of millimeters into the equivalent length in meters and meters into the equivalent length in millimeters . Q5 . write a program that calculates the volume of a sphere , given the radius by reading the radius from a file and write the result to another file ( output.txt) Volume =4/3 Ï? R3 Q6 . create a class called space which contains three data members of type integer . include member functions get data () (to read values ) and display data (to display values ) in the class space . overload the â?? operator to add the objects of type space . write this function in such way that , we can write a statement like S3=S1-S2 Where S1,S2 and S3 are objects of space . Q7)Write a program to enter some numbers and display the count of how many odd and how many even you entered. Q8) Write a program to print prime numbers between 1 and 50.( Using doâ?¦while loop and for loop ) Q9) Write a program to store 10 numbers in an array and then display the sum of digits of the largest number. Q10) Write 2 functions: int reverse (int) which returns reverse of a number and int diff(int, int) which returns difference of two numbers. Using this write a program to find whether a number given as input is palindrome or not . Q11) Write a program to input two numbers and print all the numbers within that range . Take input from a file and print output to a file . Q12) Imagine a publishing company that markets both book and audio-cassette versions of its work. Create a class publication that stores the title and price of a publication . From this class derive two classes: book, which adds a page count and tape, which adds a playing time in minutes. Each of these three classes should have a getdata() function to get its data from the user at the keyboard and a put data() function to display its data . Write a main() program to test the book and tape class by creating instances of them, asking the user to fill in their data with get data() and then displaying the data with put data().

  • c++ progeamingAbed Masri October 15, 2012 at 11:00 PM

    write a c++ program that calculates and displays the sum of all prime numbers in a user-defined closed interval [a,b] of positive integers using both pre-defined and user-defined functions.

  • two-dimensional in c++sahar October 17, 2012 at 11:08 AM

    How to fill a two-dimensional vector of size n in n +1 with two for? my code:: vector<vector<int> >v(n,vector<int>(n+1)); for(unsigned int i=0 ; i<n+1 ; i++){ for(unsigned int j=0 ; j<n ; j++){ cin>>v[i][j]; } } but it has segmentation fault!!!! thx

  • LoopSharjeel Khan October 17, 2012 at 11:45 AM

    How to write a program in c sharp in which it ask the user to enter his name , then ask the user that how many times he wanna print his name on the screen..

  • use of timer in c programbaldivya mitra December 22, 2012 at 6:05 PM

    respected sir/mam how to use a timer in "turbo c" to use timer and set a time in it for giving some questions on screen and count the time for user's reply of answer if user gives the correct answer within the time then print a well done message else print oops you late, please solve it MOSTLY FOR TIMER'S PROBLEM.

  • (c++ programming)omer October 20, 2012 at 2:55 PM

    (Explain shortly,what we mean by saying c++ is a portable languages?)

  • plz helphippo October 23, 2012 at 9:27 PM

    You are given two sorted arrays of length m and n. Give a O(log m+ log n) time algorithm for computing the kth smallest element in the union of the two arrays. Keep in mind that the elements may be repeated. First two numbers gives the size of the arrays followed by value of k.

  • plz helpsurjit October 23, 2012 at 9:29 PM

    You are planning a cross-country trip along a straight highway with n+1 gas stations. You start at gas station 0, and the distance to gas station i is di miles (0 = d0 < d1 < . . . < dn). Your carâ??s gas tank holds G > 0 gallons and your car travels m > 0 miles on each gallon of gas. You start with an empty tank of gas (at gas station 0), and your destination is gas station n. You may not run out of gas, although you may arrive at a gas station with an empty tank. As you are very rich, rather than trying to plan the cheapest trip, you want to minimize the total number of stops you need to make (you stop at a gas station only if you need to buy gas there). Assume that G, m, and all di are positive integers (except d0 = 0) and are polynomially bounded as a function of n. Assume all di are distinct. If possible, give a polynomial time algorithm to determine the value of the optimal solution (i.e. the minimum number of stops).

  • ERROR in notepad++ while running c programchirag shah November 7, 2012 at 11:00 PM

    hello when i try to integreat c compiler in to notepad++ it gave me error like "C:\Dev-Cpp\bin\gcc.exe -o $C:\Dev-Cpp\bin\gcc.exe" CreateProcess() failed with error code 2: The system cannot find the file specified. ================ READY ================ will you please give me solution?

  • C,C++Kishan Ramoliya November 10, 2012 at 12:28 AM

    Why do we need three different loops (i.e. for,while,do-while) if they are performing the same task? (Apart from the entry control and exit control concept.)

  • C PROGRAMADITYA CHOUDHARY October 26, 2012 at 4:30 PM

    /*Following is a code to find all the possible combinations of the characters of a string ,but it's not giving correct result due do some mistake.Please help. Input - no of characters in string and the string. Output - all the combinations of characters of the string. for e.g. Sample Input : enter the number of characters in the word you are going to enter 2 enter the word: os Output(it will be stored in a text file) : o s oo os so ss */ #include <stdio.h> #include <string.h> int m=0; void pos(char *a,char *b,int j,int n,FILE *fp,int k); main() { File *fp; fp=fopen("possibilities.txt","r"); char *a,*b; int n,j,k; printf("\nenter the number of characters in the word you are going to enter "); scanf("%d ",&n); a=(char*)malloc(n+1 *sizeof(char)); printf("\nenter the word: "); scanf("%s ",a); a[n]='\0'; for(k=1;k<n;k++) { b=(char*)malloc(k+1 *sizeof(char)); b[k]='0'; pos(a,b,0,n,fp,k); } printf("the number of possibilities are %d",m); printf("\nyou can find the possibilities in c:\\dev-cpp by the name-possibilities.txt "); fclose(fp); } void pos(char *a,char *b,int j,int n,FILE *fp,int k) { int i; for(i=0;i<n;i++) { b[j]=a[i]; if(j==k-1) { fputs(b,fp); fputs("\n",fp); m++; } else pos(a,b,k+1,n,fp,k); } }

  • Writing a program using C++Agah Philemon October 26, 2012 at 4:35 PM

    please help me compile and run this program Am trying to compile a program to calculate salaries and tax component of employees of an organisation and really need help. The question is: Write a program in C++ to accept the total hours worked by four workers in a certain company, and calculate their salaries and also tax component of their salaries. wage=hours worked*rate per hour salary/wage >1000 10% salary/wage > 1500 15% salary/wage < 1000 5%

  • Question on a programJeremy Spackman October 28, 2012 at 7:17 PM

    These are the instructions for the program i have to write. I'm teaching myself c++ from an ebook and i'm on chapter 7, Structers , Classes And Objects. Ups And Downs: Write a program that displays the word UP on the bottom line of the screen a couple of inches to the left of center and displays the word DOWN on the top line of the screen a couple of inches right of center. Moving about once a second, move the word UP up a line and the word DOWN down a line until UP disappears at the top of the screen and DOWN disappears at the bottom of the screen. and the one after that all i have to do is modify Ups and Downs so that they reappear starting over again and terminates when the user presses ENTER. The ebook doesn't really explain this type of problem or situation, i was wondering if you could help me do something like this in an example or give me a really awesome reference for something like this.

  • need a help!AMR November 11, 2012 at 12:18 AM

    Write a function that displays the frequency of occurrence of an element entered by the user in a stored array. The array always has the following elements: 4, 2, 7, 10, 9, 7, 6, 10, -8, 7, 9. Sample Executions: Enter a number: 7 The number 7 occurred 3 times in your array. Press any key to continue Enter a number:17 The number 17 occurred 0 times in your array. Press any key to continue

  • programming c++Hadzren November 4, 2012 at 8:54 AM

    write a program that takes as input an aruthmetic expression and verifies if it is correct.

  • programming c++Hadzren November 4, 2012 at 8:59 AM

    you need to print a grid to the screen.it is constructed with alternating rows with 17 dash and 5 vertical bars.there are 9 rows and 17 columns

  • Looping QuestionVijendra Bansal November 6, 2012 at 6:57 PM

    write a program to Print The Following? 1 11 112 1123 11235 112358 Please Fast Reply on My Email

  • c++ hesham December 23, 2012 at 6:09 PM

    Write a C++ code that implements a doubly linked list structure that contains float elements, and then do the following: 1. Implement the necessary member functions. 2. Implement a function DisplayPop(â?¦) that displays the inserted elements in a way like the pop function in the stack, Example: input= 1.5 , 3.5, 10, 0.5 output= 0.5, 10, 3.5, 1.5 3. Implement a function DisplayDequeue(â?¦) that displays the inserted elements in a way like the dequeue function in the queue, Example: input= 1.5 , 3.5, 10, 0.5 output= 1.5, 3.5, 10, 0.5 4. Implement a function DisplayEven(...) that displays only the even elements inserted by the user. i.e.: element number 0, element number 2, etc. 5. Implement a function DisplayOdd(...) that displays only the odd elements inserted by the user. i.e.: element number 1, element number 3, etc.

  • ArraysMorgan November 21, 2012 at 7:52 PM

    Write a c++ program that declares three one dimensional arrays named volt, current, and resistance. Each array should be declared in main() and be capable of holding 10 double precision numbers. The numbers to store in current are, 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, and 3.89. The numbers to store in current are 4, 8.5 6, 7.35, 9, 15.3, 3, 5.4, 2.9, and 4.8. Your program should pass these three arrays to a function named calc_volts(), which should calculate elements in the volt array as the product of the corresponding elements in the current and resistance arrays (for example volts[1] = current[1] * resistance[1]. After calc_volts() has passed value to the volt array. the values in the array should be displayed from within main(). (2) An engineer has constructed a two dimensional array of real numbers of three rows and five columns.This array currently contains test voltages of an amplifier. Write a c++ program interactively imputes 15 array values and then determines the total number of voltages in this ranges: less than 60, greater than or equals to 60 and less than 70, greater than or equals to 70 and less than 80, greater then or equals to 80 and less than 90, and greater than or equals to 90. (make use of function)

  • Filtering Data in DatagridViewTabish December 31, 2012 at 11:34 AM

    I made a program in c#, I am retrieving the data from a text file in datagridview. Now, I want a search option: I made a textbox in my form as well, All I need is, when a user types anything in the textbox, the datagridview will only show the related results by filtering. I am new to c#. please send me the code. i'll be thankful. thanks in advance.. regards Tabish

  • why its printing two different addresses ?Sree December 2, 2012 at 6:42 PM

    1 #include<iostream.h> 2 using namespace std; 3 4 5 class Base { 6 public: 7 Base() { 8 cout << hex << (void *)this<<"\n" ; 9 } 10 virtual void foo() { }; 11 }; 12 13 14 class Derived : public Base { 15 public: 16 Derived() { 17 18 Base::Base(); // line A 19 } 20 virtual void foo() { }; 21 virtual void bar() { }; 22 }; 23 24 25 int main() { 26 Derived* p = new Derived(); 27 p->foo(); 28 p->bar(); // line B 29 return 0; 30 }

  • c++Deepak kumar December 3, 2012 at 3:52 PM

    write a program that throw an arithmetic exception as an when a number input is greater than 1000.

  • C programSohail December 4, 2012 at 8:13 AM

    Please help me, I require a C program which takes two input as text files and then takes the UNION and INTERSECTIONS of the integer contents present in those two text files.

  • C questions solve this pleaseRohit December 4, 2012 at 7:07 PM

    Question is like this case 1. if(NOT(value>=1) OR NOT(value<=10) { ----- } case 2. if(NOT(value>=1) AND NOT(value<=10) {--- } q1 ; which case u r going to use the function to work for the given value either is 1 or 10 q2: --"-- value must be equal 1 and 10 options a. case 1 case 2 both neither

  • Constructor lale January 6, 2013 at 4:09 PM

    Bi class ıcınde 2 tane aynı constructor yazılamıyor diÄ?erini deÄ?iÅ?tirince hata veriyor 3 tane double parametre alması gerekıyor 2 const aynı olamaz nasıl tanımlarım yardm edermsnz ?

  • C++saif January 7, 2013 at 11:03 PM

    Hi guys. when i try to run and compile the program it shows me error as the following: Error 3 error C2011: 'Home' : 'class' type redefinition c:\users\hanash\documents\visual studio 2010\projects\myassignment\myassignment\home.h 11 1 Myassignment what does that mean 'class' type redefinition? and how i should to solve it ?

  • C++Hosein March 23, 2013 at 6:30 PM

    Hi If you have several pairs of squares and to each side of the square must be numeric. Together how that number is the same side of the face. Please help me Like 2589 8631 3291 9438 3954 5177 7123 2846 1447 4792 9348 4661 4710 1263 6887 8123 5 6 2 4 2 8 8 3 3 9 9 3 9 1 1 8 9 1 1 8 3 5 5 7 7 2 2 4 4 7 3 6 4 7 3 6 1 4 4 9 9 4 4 6 7 2 8 1 7 2 8 1 4 1 1 6 6 8 8 2 0 3 7 3 Thank

  • programmingaaa March 31, 2013 at 9:56 AM

    Suppose there are Three sections of C++ programming in this semester and there are (15) students in each section , write a program that asks the user to input the students total marks of the 3 sections (section by section ) and store the read marks in a 2- dimensional array marks[3][15] then calculate and print average of each section

  • hi I emad April 5, 2013 at 10:41 PM

    I want to write a dictionary in c++ using map in it I mean dictionary with map in c++ but I dont have time would you pls do it for me quick an english to english dictionary

  • 2d array in c++vivek pandey April 10, 2013 at 4:39 PM

    how can i store elements in 4*4 matrix in this indexing .. 00 01 02 03 13 23 33 32 31 30 20 10 11 12 22 21

  • programming in ctwity April 15, 2013 at 7:30 PM

    An array of n integers in the range 0,1,2,3...(2^k -1) is given.Each integer is written as a binary string of length k Sort the integers in O(nk).

  • about c program S Venkatesh April 23, 2013 at 4:25 PM

    why if i mention the print statement like this printf(" a%b = %d", 10%3); its not giving the ans instead of that it is printing output a%b = %d why ???????....

  • ckhushal April 24, 2013 at 1:25 AM

    int main() { char arr[20]=â??parrotâ??; char *p=arr; (*p)++; printf(â??%sâ??,p); p++; printf(â??%sâ??,p); } (A) arrot, qarrot (B) qarrot, arrot (C)parrot,arrot (D) arrot,parrot its output with explanation

  • need help in solving a c++ questionomar tarabay May 4, 2013 at 4:50 PM

    Enter a number of integer values between 100 and 200 inclusively in the edit box. Click OK button after each entry in order to accept the integer number. Clear the edit box after each entry and set focus to the edit box again in order to enter the next integer number. You have to enter exactly 5 valid values. Initially, all components are enabled except the Draw button. After you accept the fifth value, the Draw button will be enabled. ï?· If you press on â??OKâ?? button, the scenario above will be applied and the entered value will be stored in the stack which should be defined earlier and the same value will be printed on the memo. ï?· If you press on â??Drawâ?? button, the first value pushed in the stack will be fetched and a square of the same side-length value will be drawn starting from the middle of the form. Example: if the first value pushed in the stack is 150, then the side length of the square should be 150. ï?· If you press on â??Clearâ?? button, the edit box and the memo will be cleared, the drawing will be removed, the focus should be on the edit box, and OK button will be enabled. ï?· If you press on â??Closeâ?? button, then the application will be closed.

  • c programminvishwanath patil May 5, 2013 at 8:06 PM

    i want soln to this problem :print longest common subsequence of given two sequence as input using dynamic programming.e.g=sequence1=aabbbaaaab,ssequence2:aababbaaaac,o/p=aaaa;

  • doubtnj June 14, 2013 at 1:35 AM

    #include<stdio.h> #include<conio.h> void main() { short int a=5; clrscr(); printf("%d"+1,a); getch(); }

  • textNavjot singh June 15, 2013 at 9:53 PM

    i have problem in solving a pattern making programme...plz help if u can a abb abbccc abbcccdddd

  • reading from a file with fscanfmehrdad June 20, 2013 at 9:39 PM

    hello i want to read data from a text file wich have 4 lines and i want to read line 4.i use fscanf function but the function always read line 1 and it doesn't matter if i use \n or not please help me

  • function calling by nameanshu June 22, 2013 at 8:36 PM

    how to implement function calling by name . and tell me the answer of this code by function calling by name. #include <stdio.h> #include <string.h> int fun(int i) { i=5; return i; } main() { int k=3; printf("%d %d",fun(k)*3,fun(3)*3); //getch(); }

  • Problem in inputAnuj June 30, 2013 at 8:29 PM

    Hey , suppose I made a simple factorial program in C , which takes a user input. I wish to give the input from a .txt file in which the number of which I want the factorial is written. How do do this simply using command prompt or anything. Please dont tell me to open the text file using fopen and f.gets functions.

  • C++ Sohail Malik July 9, 2013 at 9:38 PM

    Dynamic memory allocation by using pointers provides an efficient way of utilizing computer memory but such memory allocation may be problematic if not handled properly in program. Anybody help me about this concept...

  • can give the coding fo r this.........nethmi July 14, 2013 at 10:30 AM

    AS class called "Names" has already been implemented to store the names of a set of students. the methods insert(),delete() and find() return true if the operation is successful otherwise it returns false. Names(int maxEliments) bool insert(char[]) bool delete(char[]) bool find(char[]) void display()

  • c++deepika August 4, 2013 at 9:17 PM

    1st claa record filed employid,name,address,phon no.& made 2nd class office filed salary,duration using friend function& use inumtex

  • question regarding RETURN keyword.karan July 29, 2013 at 11:15 PM

    sort( int b[ ]) { b[i]=b[i]+b[i+1]; b[i+1]=b[i]-b[i+1]; b[i]=b[i]-b[i-1]; return ??????? } what should return this sorting function... actually i have called this function in main() but problem is what should i write in return....plz hel

  • output with explanationUjjwala meshram September 24, 2013 at 1:08 PM

    #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j; for(i=1;i<=10;i++) { for(j=1;j<=i;++j) cout<<"#"; for(j=9;j>1;--j) { for(j=1;j<=i;j++) cout<<"*"; cout<<'\n'; } } }

  • conditional operatorsamila kasun August 6, 2013 at 11:14 PM

    why we cant use.....like this char currency[2][3]; if(currency[0]=="A"){ .......... } (is it because of the null) then how i correct that.......

  • conditional operatorsamila kasun August 6, 2013 at 11:16 PM

    why we cant use.....like this char currency[2][3]; if(currency[0]=="A"){ .......... } (is it because of the null) then how i correct that.......

  • c++Arslan August 16, 2013 at 11:19 PM

    Input an integer containing only 0s and 1s (i.e., a “binary” integer) and print its decimal equivalent. (Hint: Use the modulus and division operators to pick off the “binary” number’s digits one at a time from right to left. Just as in the decimal number system where the rightmost digit has a positional value of 1 and the next digit left has a positional value of 10, then 100, then 1000, etc., in the binary number system, the rightmost digit has a positional value of 1, the next digit left has a positional value of 2, then 4, then 8, etc. Thus the decimal number 234 can be interpreted as 4 * 1 + 3 * 10 + 2 * 100. The decimal equivalent of binary 1101 is 1 * 1 + 0 * 2 + 1 * 4 + 1 * 8 or 1 + 0 + 4 + 8, or 13.)

  • why output is in infinite loop explanationujjwala meshram September 24, 2013 at 1:17 PM

    #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j; for(i=1;i<=10;i++) { for(j=1;j<=i;++j) cout<<"#"; for(j=9;j>1;--j) { for(j=1;j<=i;j++) cout<<"*"; cout<<'\n'; } } }

  • c output in cmdPiyush September 8, 2013 at 1:20 AM

    sir i use cmd and mingw for compiling c programs. i want to ask that whenever i run a menu driven program and run it and give by mistake a char input instead of int... it goes into infinite loop and does not stop... how do i set it to display message as "Invalid Input" and ask the input value again. i have used while(1) as the menu driven loop which breaks at ch=4. ch input is accepted in the while loop itself.

  • need your helpRavindra Nath Manish September 19, 2013 at 12:08 PM

    #include<stdio.h> void main() { printf("hey now i am trying to connect to database \n"); if(system("rm a.cpp")); printf("a.cpp file removed sucessfully"); if(system("sqlplus EPRINT_NET1/EPRINT_NET1@10.50.58.57:1521/orcl \n select process_id_n from prn_query_master;")); printf("database connected please run your query ;"); //if(printf(system("select process_id_n from prn_process_master"))); } comments:::i made database connection without using api.now i want to give sql command from our program.i tried many times but still unsucessfull please help me out

  • c/c++Ruan September 26, 2013 at 7:18 PM

    I am a begginer at c/c++ and I can not seem to make this work at the end, can someone please help me? #include<stdio.h> #include<math.h> int main() { int feel; printf("How are you feeling today? "); printf("Choose between 1 - 5! "); scanf("%d", &feel); if(feel < 2){ // 1 if(feel > 0){ printf("You are feeling very bad! \n"); } } if(feel < 3){ // 2 if(feel > 1){ printf("You are just feeling bad! \n"); } } if(feel < 4){ // 3 if(feel > 2){ printf("You are feeling between bad and good! \n"); } } if(feel < 5){ // 4 if(feel > 3){ printf("You are just feeling good! \n"); } } int question printf("Is that correct? Yes or no! "); scanf("%d", &question); if(question - "no"){ printf("You are lying!!! \n"); } if(question - "yes"){ printf("I know that! \n"); } } I am trying to make a program that asks you a question(How are you feeling today?) and then you have to type a number from 1 - 5. at the end it doesn't work. I don't know how work with if/else that well. can someone help me, as you can see I am a real BIGGINER.

  • Unary and Binary Operatorsnouno tkd October 23, 2013 at 12:32 AM

    Write a program that clear the difference b/w increment & decrement operators using binary & unary operators. can anyone solve this. then help me plz.

  • c++GNG Ntim November 19, 2013 at 7:24 PM

    create a class using c++ called Advertisement.Advertisement consists of ID,advert type,description,start date,end date,start time,end time and number of times to be played in a day.the advertsiemnt object should contain a contructor that accept all the details of advertsienmt and save it in a file.it should contain a method called playAdvert which accpt the ID of the advert and plays it by just displaying the name oh the advert to the screen.

  • c++Lilu November 28, 2013 at 2:32 AM

    C++ program Hi, I can't get this program to ask a 10 random question with a random month name. Please help. Add Media it needs to look like this: Example: RUN How many days are there in the month of March? 28 No March has 31 days. How many days are there in the month of November? 30 Correct! Your total score is: Here is my code: #include<iostream> #include<iomanip> #include<cstdlib> #include<ctime> int total=0; using namespace std; int main() { cout<<endl<<endl; int days [12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string names[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} ; int i, ans; unsigned int seed; seed=time(0); srand(seed); for (i = 0; i < 12; i++) { names[i]=1+rand()%12; cout<<"How many days are in a month of" <<names[i]<< "? "; cin>>ans; } if (ans==days[i]) { cout<<"Correct"; total+=10; } else { cout<<"Incorrect"<<endl; cout<<"No "<<names[i]<< " has "<<days[i]<< "days "; } cout<<"\n\nYour total score is: "<<total; return 0; }

  • loopsBukar November 28, 2013 at 3:40 AM

    Anyone to explain this statement if(row==column||column==height-row+1)

  • c programming questionParijat Mondal May 24, 2014 at 8:44 AM

    what is the advantage of using double pointer in linked list instead of single pointer? I want point wise answer.

  • haxa to grayjai March 9, 2014 at 1:11 PM

    I want c code to convert 8 byte haxa value to binary.. ex temp=0xaf; I need to convert this haxa value to binary ..

  • structures and enumsmukul mehra June 6, 2014 at 5:06 PM

    hi i need to copy into a structure ,values from a location using a character pointer. the structure has some members that are enum types. can i do it using memcpy??

  • C++Dilawer April 13, 2014 at 11:14 PM

    Write a program segment that uses this method to calculate and print the square of a number. The program should prompt the user to enter an integer, then use this method to calculate and then print the square of the integer entered. Use a do-while loop. Solve this

  • c++ program saki May 9, 2014 at 8:17 AM

    c++ program for finding crictical bridges

  • C++programming help!!!!Zach August 2, 2014 at 3:50 AM

    Write the definition of a function isMultipleOf , that receives two integer arguments and returns true if the first argument is a multiple of the second. Otherwise false is returned. So, if the arguments are 27 and 8 the function returns false because 27 is not a multiple of 8. But if the arguments are 34 and 17 the function returns true because 34 is a multiple of 17 (2*17 is 34).

  • c++ programmingMichael Gaytan September 1, 2014 at 11:21 AM

    hi I need help to display to write out a game loop here is the portion for the game loop but I don't get what to put in order to display names from a pointer and update the input. I also put the code that involves with the pointer as well on the bottom that I believe is what needs to be updated. please help. void View::play(){ //Game Loop while (controller.isGameInProgress()) { //Get current player input string gameLoop = " "; cout << "1.Hit" << endl; cout << "2.Stay" << endl; getline(cin, gameLoop); if (gameLoop == "1"){ cout << "A card is dealt." << endl; } else if (gameLoop == "2") { cout << "Player stays." << endl; } else { cout << "Invalid input" << endl; } cout << endl; //update the game(controller) //Update the view } } void Controller::newGame(int number, string names[]){ numberOfPlayers = number; players = new PlayerModel*[number]; for (int index = 0; index < number; index++) { players[index] = new PlayerModel((index + 1), names[index]); } currentPlayerNumber = 1; gameInProgress = true; } bool Controller::isGameInProgress(){ return gameInProgress; }

  • C++umashankar mishra July 4, 2011 at 10:19 AM

    pls tell me the difference between deep cop and shallow copy with example...and pls give me full explnation through my mail...

  • C Languagesathyananarayanan July 10, 2011 at 5:26 PM

    What is structured programming language?why c programming language is called structured programming language?

  • C Languagesathyananarayanan July 10, 2011 at 5:30 PM

    what is structured programming language?why c programming language is called structured programming language?

  • algorithm and problem solvingkemi September 9, 2011 at 6:57 AM

    At Olympic diving competition level, ten diving judges award a single mark (with one decimal place) for each dive attempted by a diving competitor. This mark can range from 0 to 10. Design an algorithm that will receive a score from the ten judges and call a method to calculate the average score. The screen should display the following output: Judge 1 2 3 4 5 6 7 8 9 10 Mark 6.7 8.1 5.8 7.0 6.6 6.0 7.6 6.1 7.2 7.0 Score for the dive 6.81

  • algorithm and problem solvingkemi September 9, 2011 at 6:59 AM

    A painter would like to know the amount of paint needed to paint only the walls and interior side of the door in a room. The chosen paint can cover 100 square feet per gallon. There are two windows in the room. Call a method to solve the problem with the following data: The room is 12 feet long, 8 feet wide, and 10 feet high The two windows are 4 by 4 feet, and 5 by 2 feet, respectively

  • c++rony October 20, 2011 at 3:47 PM

    a problem in increment order.. for eg. int b=1,c; c=++b + ++b; then wht is value of c,i'll got c=5,but computer show c=6;

  • C++ questionSavi November 2, 2011 at 1:12 AM

    Write a program that does the following: •Input is a list of (any number of) n positive integers, terminated by input of -1. •Output is a (sideways) histogram which represents the list of numbers. Specifically, the output consists of n lines. Each line i consists of x asterisks, where x is the ith number in the input. •The output must not start until after the user is finished typing input. Here is an example of input/output behavior of the program: <br>Enter a list of positive integers, ending with -1<br>4<br>2<br>8<br>1<br>5<br>-1<br><br>Here is the output<br><br>****<br>**<br>********<br>*<br>*****<br>

  • csai February 2, 2012 at 9:53 PM

    #include<stdio.h> static int i=5; void main() { printf("hello\n"); for(i=1;i<7;i++) { main(); } } the above program printed "hello" infinitely...can anyone please explain that?

  • C++ programming albert March 6, 2012 at 12:04 AM

    Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will out that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.

  • code optimisationShivaraj Patil April 30, 2012 at 11:58 AM

    Please Suggest me optimised code for this simple code. Optimised code should not contain for loop. #include<stdio.h> int main() { int i; int a = 20; int *ptr = malloc(2500 * sizeof*(int)); for(i = 2500; i > 0; i--) { *ptr++ = a; } return 0; }

  • Mind blowing bugsam August 24, 2012 at 11:37 PM

    Hello, I'm programing for about a year now ( but not on C ) and i'm trying to get use to pointer in C, so i'm doing a little exercice. BUT I have a problem with "scanf" function here is my code : #include <stdlib.h> #include <stdio.h> typedef struct node { int n ; struct node *next; } node; main() { int tmpchoice = 10; int val,i,choice; node *first = NULL; node *tmp = NULL; const int SIZE = sizeof(node); do { printf( " --MENU-- \n\n 1- Display\n 2- Insert (at the end)\n 3- Find\n 4- Delete any occurrence\n 5- Sort\n 6- Insert in sorted list\n 0- Exit\n\n"); scanf("%d", &tmpchoice); choice=(int) tmpchoice; printf("\n"); tmp=first; /* then there is a switch which is sertenly not the problem. I commented it and it still doesn't word */ } while(choice != 0); Well "scanf" dicided not to get executed after the first time when I enter a CHAR instead of an INT and it causes an infinit loop. Does ANYONE know what is the problem ?

  • c languegevanjara kishan August 25, 2012 at 8:17 PM

    enter a value and cheque it is devide by 5or 7 in c language

  • Please, help me about bisection method in C +?wanu November 7, 2012 at 1:01 PM

    Please, help me about bisection method in C +? Obtain the local minimize of the function f(x) = X5-5X3-20X+5 on [-3,O] and [0,3] by bisection method >> and run it in a loop help me++++

  • c++programmingnini November 27, 2012 at 12:56 PM

    Write an array declaration statement that stores the following values in an array named volts : 16.24, 18.98, 23.75, 16.29, 19.54, 14.22, 11.13, and 15.39. Include these statements in a program that displays the values in the array.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
General

Ask C/C++ Questions online
Ask C/C++ Questions online       C and C++ are different programming language, but both the languages are popular among programmers. C is a general 

Java Beginners

basic c/c++ questions
basic c/c++ questions  Are the Control statements like if(),while() in built functions? if no, why not as they satisfy all the properties of a function 

Java Beginners

basic c/c++ questions
basic c/c++ questions  Are the Control statements like if(),while() in built functions? if no, why not as they satisfy all the properties of a function 

Java Beginners

C/C++ QUESTIONS
C/C++ QUESTIONS  ??Write a function for finding out the occurences of repeated word from a sentence. This function would return an array of duplicate words. 

Java Beginners

C/C++ QUESTIONS
C/C++ QUESTIONS  "Write a function for finding out highest and lowest marks obtained by a student from an array contained student name and marks". For Example : GetHighestLowestMarks{Student{n}, Marks{n}} returns 

Development process Questions

C,C++
C,C++  Sir, 100&30 gives output 4 in C++ and 100|30 gives output 116 How & and | gives output 4 and 116 

Development process Questions

C,C++
C,C++  int i=100,j=20; int c=i&j; int r=i|j; printf("%d",c); printf("%d",r);   #include<stdio.h> #include<conio.h> void main(){ int i=100,j=20; int c=i&j; int r=i|j; printf("%d",c); printf("%d",r 

Development process Questions

c/c++ - Development process
c/c++  Creating animation using c/c++. The code for moving an object using c/c 

Java Beginners

variable declaration in c and c++
variable declaration in c and c++  Comparison and an example of variable declaration in C and C 

Development process Questions

c/c++ - Development process
c/c++  I need the code for developping two dice and roll them using c/c++. Thanks 

Development process Questions

C/C++ - Development process
C/C++  I need the code for playing the backgammon game using C/C++.Im using turbo C. I`ve already design the board.I badly need the code for playing this game 

Java Beginners

c c++ - Java Beginners
c c++  Write a Multi-user chat server and client  Hi Friend, Please visit the following link: http://www.roseindia.net/chatserver/index.shtml Hope that it will be helpful for you. Thanks 

Java Beginners

c or c++ - Java Beginners
c or c++  Write a program for a two user chess game(Users must be on different systems)? please send me this source code to my mail id with step by step explanation 

Development process Questions

c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks 

Development process Questions

c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks 

Free C++ books

C/C++ Programming Books
C/C++ Programming Books         Visual C++ 6 Unleashed Visual C++ 6 Unleashed provides comprehensive coverage of the core topics 

Swing AWT

c c++ - Swing AWT
c c++  Write Snake Game using Swings  Hi Friend, Try the following code: 1)SnakeGame.java: import javax.swing.JFrame; public class SnakeGame extends JFrame { public SnakeGame() { add(new Snake 

Java Beginners

c c++ - Java Beginners
c c++  Write a small record management application for a school...]; String name = f[1]; String c = f[2]; String note = f[3...]; String name = st[1]; String c = st[2]; String note = st[3]; if (id.equals 

XML Questions

Difference in XML, C, C++, Java
Difference in XML, C, C++, Java  hi... What is the difference between XML and C or C++ or Java ? please tell me about that Thanks 

Java Beginners

C/C++/JAVA Question on function
C/C++/JAVA Question on function  "Write a function to find out common... other data type also.â?? Question can be solved in C,C++ or JAVA. (Recommneded - C 

Eclipse Plugins

EasyEclipse for C and C++
EasyEclipse for C and C++       EasyEclipse for C and C++ is all you need to start developing C and C++ code with Eclipse. There are currently 28 comments 

Development process Questions

oopengl on3d using c/c++ - Development process
oopengl on3d using c/c++  sir i want a programs on opengl in 3d using c/c++ language give me new one sir 

Java Beginners

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

Java Magazine Questions

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

Design concepts & design patterns Questions

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

Java Interview Questions

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

Java Beginners

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

Java Beginners

online quiz
online quiz  Define a Question class which stores a multiple choice... of up to 10 questions. Define the add method of the Quiz class to add a question... approach to populates a quiz, presents it by asking questions randomly 

WebSevices Questions

online exam portal
online exam portal  i am thinking of developing a small online exam pattern with multipe choice questions , can u please give me any idea of how to start 

IDE Questions

Linux - IDE Questions
Linux notes  Hi, Could u plez send a material & online notes ,which is good start for a new users to linux environment. Could u clear doubts on C/C++ language ? Reply ASAP 

DMCA.com