Sunday, August 2, 2009

I know the c programming but how can i communicate the analog to digital in programming?

I Have gone to C Class but they only thought the basics but i want to write program by own.

I know the c programming but how can i communicate the analog to digital in programming?
you need an analog to digital converter. there are many out there so how to interface it to your C program will depend on the type you get. some are serial data and some are parallel data. just check the data sheet and it will tell you how to interface to it. you may even be able to find example code on how to do it.
Reply:Any way thanks for your answer Report It

Reply:Use Matlab.
Reply:yeah of course,





actually i have tried that way of communicating the analog to digital..i have tried to make the toy train move forward or reverse using a program i made in VB..





but in C, you can also communicate those analog circuits..





i used the IO.dll





in C you can also apply that IO.dll to communicate analog to digital..





it's actually called interfacing..you can search for interfacing codes in the internet..the C is a very powerful programming language to do that task..





but just remember, you cannot interface when you are running kernel mode operating systems like the XP,


UNLESS you make use of a third party programs like the porttalk..Ü





i believe you can do that..goodluck!


I have studied C programming language and would like to do a small project in C. Can you help me please..?

I googled to find any C language projects with the source code but could not find anything otherthan in the" Fresh Meat " site which are all lengthy programs like MPlayer and GCC. I would like to do a project with around 1000 lines and preferrably with details like flowchart..please give me the links , if you know any..

I have studied C programming language and would like to do a small project in C. Can you help me please..?
better go with balaguru swamy
Reply:If you want a project that small - make one up!!!





Use your imagination and think of a small utility that you could make, then design your flowcharts etc and write it!
Reply:It is better, you have to make the project from your own ideas. But sure, you must have some guidence lines from the C projects. with those guidence, you can make your own thing like a small database program to keep track of addresses and telephones or any kind of small utility. You can get ideas from the following book written by YASHAVANT KANETKAR.


he is having so smart ways to explain the internal arthimidic of C language.


Book is C Projects., BPB publications. This is availabe from Hikin Bothams.

queen of the night

How retain the data in a variable in C programming( not C++) after closing the program???

Iam trying to make a information system using C, not C++ but i want to save the changes done when i open my program and close it and when i open again it does'nt go back to the original but the retains the changes done.


Meaning A was originally 1 but when i run the program i changed A into 3 and when i close the program and then open again i want A to be 3 not 1.


Can anyone help cause i cant seem to understand the tutorials in the internet.


tnx :)

How retain the data in a variable in C programming( not C++) after closing the program???
Store the data in a file. When the program starts up, read the values from the file. When the program ends, write the new values to the file.





Suppose you want variables a, b, and c... (double-check my syntax)








FILE *iniFile;





/* Open the file and read in the values */


if ( (iniFile = fopen("mydata.ini","r"))==NULL) {


printf("Unable to open file for read!\n");


exit 1;


}





/* Read in the values */


if ( fscanf(iniFile, "%d %d %d", %26amp;a, %26amp;b, %26amp;c) != 3 ) {


printf("Error - not enough values on ini file\n");


}


fclose();








/* Write out new values -


NOTE: this wipes out previous values */


if ( (iniFile = fopen("mydata.ini","w"))==NULL) {


printf("Unable to open file for write!\n");


exit 1;


}





/* Write out the values */


if ( ! fprintf(iniFile, "%d %d %d", %26amp;a, %26amp;b, %26amp;c) ) {


printf("Error - unable to write file\n");


}


fclose();
Reply:When you close the program just save any variable or change or whatever in an external file (such as a*.cfg file or what you like the most).


How do I do this C programming???

I'm trying this "hello world" program and every time I compile the SC, this error message appears:


C:\Program Files\Miracle C\hello.c: line 1: Parse Error, expecting `SEP'


'1: include %26lt;stdio.h%26gt; 2: 3: int radius, area'


aborting compile

How do I do this C programming???
since you didnt show your code, the only thing I see is "include %26lt;stdio.h%26gt;" should be #include %26lt;stdio.h%26gt;, and int radius, area should be int radius, area;. Other than that, who knows without seeing the code you wrote.
Reply:post the source code
Reply:I think there are two booboos here. Try :





#include %26lt;stdio.h%26gt; /* No ; after the lines with a # */





int radius, area; /* Must have ; after normal lines of C */





This is true because the first line is a line intended for the C preprocessor. The second line is a line of standard C code, declaration of two integers named radius and area, to be specific.





I hope this will help you out with the general format.
Reply:All preprocessor directives start with #


That is, instead of


include %26lt;stdio.h%26gt;


mut be:


#include %26lt;stdio.h%26gt;
Reply:The error message is specific to the compiler you're using: Miracle C (http://www.c-compiler.com/guide/errmessp... ). To put is simple, expecting a SEP means the compiler expects you to put a semicolon in a place that you don't put a semicolon in.





AFAIK, preprocessor functions isn't ended with a semicolons, so your code should actually compile correctly.





My guess is, perhaps your DOS environment doesn't recognize the symbol #, so it passes the # symbol as nothing, and this makes Miracle interpret it as a normal C functions. The reason for this is: the error message states "1: include ... " %26lt; the # doesn't appear on this message, while you actually have a # in the source code.
Reply:Which compiler are you using ,programming an hello world in c program is the easiest one .


In Linux , open a text file using vi editor and type your program , save it using wq! , and type gcc %26lt; program name%26gt; . this will create a.out , run that , if any args needed from command line. For other os , search in google.


Visual C# Programming Project?

I am in a computing class in my school that allowed us to learn what ever we wanted, so long as we were learning at a decent pace and the instructer knew what we were doing.


Anyways, I chose to teach myself Visual C# and I learned alot of the basics in coding, as well as creating forms.





After 9 weeks though we have to submit a project review thing that shows what we have done, and I want to code something that can demonstrate what I have learned, but cant come up with any cool ideas.





Anyone know of something I could do, even if its abit harder if you know of a tutorial or something that makes a cool program, or even a full project already done that allows you to edit it and customize it ect.

Visual C# Programming Project?
Well the good way to gain brownie points and actually do something that you can write on your resume is work on an open source project either fixing code or adding features. Unfortunately MS is not very friendly with Open source so I really dont know any projects in c#. Try doing something web related like a online diet diary or fitness tracker etc. The problem with web apps is that if you do not know what you are doing you can make your code insecure and get hacked.


In c programming language, when printing(ie printf), how do i align the data?

i have to do a program wherein it is necessary to align the data. it's like a table but without the lines. is there any function in c that will allow me to print in a particular value in a specified row and column area? using tabs wouldn't work because the data values have varying lengths thus ending up unaligned.

In c programming language, when printing(ie printf), how do i align the data?
Yea you can do it by using %+d and %-d. Just use them and see what happens.
Reply:You mean formatted output in c?


chek this or similar links maybe


http://www-ccs.ucsd.edu/c/lib_prin.html
Reply:Formatting the output can be done directly within that "%f %s \n..." portion, %.2f means output by 2 decimal places, but i really don't recall much from those, more than that you may need to create some intermediate string manipulation code to achieve what you want.

baby breath

A problem of C/C++ programming language........?

Is there any web site where I can search any C/C++ program????

A problem of C/C++ programming language........?
Search existing programs? Google Code Search. If you're asking about learning, that's a different question.
Reply:I have observed in yahoo answers that there are people who are in need of such basic programs. For those I am going to create a blog with the simple c, c++ programs written in TurboC. The blog will be up within one week. Keep in touch.
Reply:cplusplus.com or google it


Can anybody help me with c++ version six programming?

Use functions :


1. Write C++ program to convert Celsius degrees to Fahrenheit. The program should request the starting Celsius value, the number of conversions to be made, and the increment between Celsius values. The display should have appropriate headings and list the Celsius value and the corresponding Fahrenheit value. Use the relationship:





Fahrenheit=(9.0/5.0)*Celsius+32.0





2. Write a C++ program that returns the fractional part of any user entered number. For example, if the number 256.879 is entered, the number 0.879 should be displayed. (Hint: Use an int cast). Enter, compile, and execute the program.





please help me thanks!

Can anybody help me with c++ version six programming?
for number 2:





#include %26lt;iostream%26gt;





int Int;


float Float, Fraction;


int main() {


std::cout %26lt;%26lt; "Enter a number with a fractional part: " %26lt;%26lt; std::endl;


std::cin %26gt;%26gt; Float;


Int = (int)Float;


Fraction = Float - Int;


std::cout %26lt;%26lt; std::endl %26lt;%26lt; Fraction;


return 0;


}
Reply:double Fahrenheit,Celsius;


scanf("%1f",%26amp;Celsius);


Fahrenheit=(9.0/5.0)*Celsius+32.0


printf("%1f",Fahrenheit);

clear weed

Any C# programming pro??

HELP!! i'm doing an assignment using C# program and i don't know how to do the codings part. anyone can help??

Any C# programming pro??
You can find many C# experts at websites like http://getafreelnacer.com/
Reply:Sure,what kinda program are you doing? paste in your sample code and ask your doubts.
Reply:Give something more concrete.





Shoot me an e-mail





freakish777


[at]IHATESPAM


gmail


[dot]


com
Reply:We can help you if you post particular detailed questions about problems you are facing.





That's how this Yahoo! Answers works.
Reply:what can i help you?
Reply:WWW.PROGRAMMERSHEAVEN.COM





GO THERE AND IT WILL RESOLVE YOUR PROBLEMS AWAY..


1. What are the main features of c++ programming language (OOPL)?

Explain how c differs c++ its structure. Give examples.


With a simple structure that describes the structure of a c++ program


Explain what is a variable


Briefly describe the basic data type


Write a program that solve quadratic equation


write a c++ program that determine the principle amount of money for a period of a fixed interest

1. What are the main features of c++ programming language (OOPL)?
Dig the link





http://en.wikipedia.org/wiki/C++
Reply:c differs from c++ in its name itself


c++ is addition of something to c language


that something is classes .


so c with classes is c++.


c++ is an object oriented language where as c is a structured pgmg language.


examples : c doenst exhibit oops principles.


ie inheritance ,polymorphism and so on.


a variable is that which keeps on changing i.e, varying


ex: int a =1;


cout%26lt;%26lt;a;


o/p is 1


if


int a=1;


a+=2;


cout%26lt;%26lt;a;


o/p is 3


ie a changes during execution of a program
Reply:C++ was developed by Bjarne Stroustrup as "A better C" (it was originally called "C with classes"). At a talk, I recall Bjarne saying that he was doing some simulation work while a student at Cambridge, and found himself wishing for a language combining the object-oriented features of Simula and the performance of C. C++ was the result. (For a little more history, and some links, see this page on the history of C++.)





C++ was one of several efforts to add OO features to the popular C language. The other prominent one was Objective C, probably best known for its use on the NeXT platform. Whereas C++ is strongly typed and focused on performance and C compatibility, Objective C is more in the style of Smalltalk. Though still active, Objective C is much less used than C++; and both have been eclipsed by Java since the late 1990s.





C++ extends the C language with objects, classes, and inheritance. Unlike Smalltalk, it supports strong typing, and unlike both Smalltalk and Java, it supports multiple inheritance. Also unlike Smalltalk and Java, it does not use garbage collection; as in C, programmers explicitly allocate and free object storage. Because of these factors (and others), C++ is more complicated than either C, Java, or Smalltalk.





This tutorial covers only a small fragment of the language, mainly through examples. It does not assume a prior knowledge of C. Some comparisons to Smalltalk are made to illustrate the differences between the languages, and there are a few references to the differences between C++ and Java.





To understand C++, it is first necessary to know a little C. Keep in mind that any C program (as long as it conforms to the ANSI standard for C) is automatically a C++ program, since C is a subset of C++. The following, from the famous Kernighan and Ritchie book, is a simple C program:





#include %26lt;stdio.h%26gt;


main () // A very simple program


{


printf("hello, world\n");


}





The #include embeds definitions from the standard I/O library needed for the printf statement. Every C and C++ program has a main() function, which is called when the program is executed. Braces ( { } ) delineate blocks of statements, in this case the single statement making up the body of main(). This statement prints "hello, world" when the program is executed ("\n" is the code for carriage return/line feed). The semicolon terminates a statement (notice the difference from Smalltalk, where a period terminates a statement, and semicolon delineates a series of messages to the same object). The double quote is the character string delimiter in C; the comment delimiter is a double slash (//). Comments may also be delimited by bracketing them with "/*" and "*/".





Variables in C may be primitive types, such as characters and numbers:





char c = 'c'; // Character


int i = 10; // Integer


double x = 12.34 ; // Floating point number





Or they may be arrays of primitive types:





char c[] = {'c', 'h', 'a', 'r'}; // Array of characters (string)


char c[] = "char"; // Alternative way of initializing a string


int i[] = {2, 3, 5, 7}; // Array of integers





Arrays are referenced by the index of their elements, starting at zero for the first element; e.g., c[3] returns 'r'. (Note that other languages, such as Smalltalk, use 1 as the index of the first element in an array).





C variables may also be structures, containing other variables of different types. For example, the data associated with a bank savings account might be represented as:





struct savingsAccount {


int balance;


int accountNumber;


char name[30];


};





The individual variables, or members, of the structure are referenced by qualifying the structure name with the member name:





struct savingsAccount myAccount;


// Initialize the new account


myAccount.balance = 0;


myAccount.number = "1234";


myAccount.name = "Dave Collins";





In addition to main(), a program can have any number of other functions:





#include %26lt;stdio.h%26gt;


int cube(int x) {


return x * x * x;


}


main () {


int i;


for(i = 1; i++; i %26lt; 10)


printf(i, " cubed is ", cube(i));


}





This example adds the function cube(int x), which returns x3 and is called from main(), plus a few other constructs. The expression i++ is common in C and C++ (in fact, it gives rise to the name "C++"); it means "use the value of i, then increment i by one." The entire for expression means "start with i set to 1; use i in the statement (or block of statements) after the for; increment i by 1; keep doing this until i gets to 10; then continue the program after the for."





The C if and while control structures resemble the for. Here is an example of if:





int i, j;


if (i == 0) {


j = 10;


i++;


printf(i);


}





Notice that the equality test in C is ==, and = is used for assignment. Most other operators are like those in other languages; != means "not equal."





You will frequently encounter in C programs the rather cryptic variant





if (!i) . . .





instead of





if (i == 0) . . .





This works because C does not have a boolean type; instead, it uses 0 for false, and any integer greater than zero for true. Thus !i means "i is false," which is precisely equivalent to i == 0.





C and C++, unlike Smalltalk, explicitly differentiate accessing an object directly (by value) from accessing it through a pointer (by reference). This is illustrated in the following example:





int sum1(int x, int y) {


return x + y;


}


int sum2(int *x, int *y) {


return *x + *y;


}


int result1, result2;


int i, j; int *pi, *pj;


i = j = 10;


pi = %26amp;i; pj = %26amp;j;


result1 = sum1(i, j);


result2 = sum2(pi, pj);





The variables i and j are declared as integers and set to 10. The variables pi and pj are declared as pointers to integers, and set to the addresses of i and j (int *i means "the object pointed to by i is an integer"; %26amp;i means "the address of i"). Pointer references are useful when objects are large, because passing a pointer is faster than copying the object. They are needed when objects are dynamically allocated, since their locations are not known at the time the program is compiled.





It is worth noting that the explicit use of pointers, and the programmer-controlled distinction between value and reference, were dropped in Java. Java still has the distinction, but it is handled automatically: "primitive" types (such as integers) are always accessed by value, complex types (objects and arrays) are always accessed by reference. Creation and dereferencing of pointers is handled automatically "under the covers," so the programmer is not explicitly aware of it. This is a significant simplification, which undoubtedly contributed to Java's popularity.





Pointers allow the programmer to statically compile only a pointer, then dynamically allocate storage for the creation of data structures or objects at runtime. For example:





struct savingsAccount *myAccount;


int size = sizeof(struct savingsAccount);


. . . .


// Allocate storage for the account


myAccount = (struct savingsAccount *) malloc(size);


myAccount-%26gt;balance = 0;


myAccount-%26gt;accountNumber = 1234;


myAccount-%26gt;name = "Dave Collins";


. . . .


// Free the storage used for the account


free(myAccount);





Note that the storage gotten with malloc must be explicitly released using free. Otherwise, it will be released only when the program ends, and the program may exhaust all the available storage if large numbers of objects are created. It is also important that the storage not be freed while it is still in use. Notice also that whereas a direct structure reference uses dot notation (e.g., myAccount.balance), structure reference via a pointer uses an arrow (e.g., myAccount-%26gt;balance).





The operation in the fifth line of the above example, (struct savingsAccount *), is a cast, explained below. It tells the C compiler that what is returned by malloc, which is a pointer to a block of storage, is now to be treated as a pointer to a savingsAccount structure.





Storage management in C++ is also the responsibility of the programmer; objects created using new must be released using delete, otherwise their storage will not be freed. In some cases (beyond the scope of this tutorial) the programmer must code a destructor function to free storage held by objects of a given class.





Storage management is a major source of errors in C and C++ programs. Some other languages, such as Smalltalk and Java, use garbage collection and do not permit programmers to manage storage usage explicitly. The garbage collector runs periodically, and determines whether any references exist to objects. If not, the objects are deleted and their storage is freed. C++, in order to insure that maximum performance can be attained, does not use a garbage collector. The designers of Smalltalk and Java argued that the small additional overhead is a reasonable price to pay in return for not being exposed to storage allocation and deallocation errors made by programmers.





One more feature of C that is relevant to C++ is the notion of a cast. Casting is changing the type of a object. As an example of why this might be necessary, the standard C library function sqrt(), which returns the square root of its argument, takes a floating-point double as its argument. Suppose we want the square root of an int (integer)? The cast operator (double) performs the appropriate conversion before calling sqrt():





int i;


double x, y;


i = 5;


x = (double) i;


y = sqrt(x);





Casting can be dangerous; what will be the result of this?





int i;


char name[30];


double x, y;


i = 5;


x = (double) name;


y = sqrt(x);





Hopefully a warning from the compiler, possibly a hard-to-find runtime error if the warning is ignored. There is no explicit casting in Smalltalk, though it may happen "under the covers," resulting in runtime errors if the object to be converted is the wrong type. C++ (and Java) also permit C-type casting, but provide facilities for making it safer.





C++ adds objects, classes, and inheritance to C. The equivalent of a method in C++ is a member function; this is just like an ordinary C function, except it is defined as part of a class, and has an implicit argument that is the object receiving the "message." The equivalent of a message in C++ is a member function call. Because objects in C++ can be referenced directly or through a pointer, there are two somewhat different equivalents for Smalltalk’s message sending:





SavingsAccount account;


SavingsAccount *pAccount;


int a, b;


pAccount = new SavingsAccount;


a = account.balance();


b = pAccount-%26gt;balance();





The object account is allocated when the program is compiled. The pAccount declaration only allocates a pointer, and the assignment to new SavingsAccount dynamically allocates the object it points to. Direct references to object member functions use the "dot" (.), and references by pointer use the -%26gt; notation. (Java, since it has no explicit pointers, uses only the dot notation.) Note the similarity of the dot and arrow notations to what is used to access structure members in C. A C++ class can be thought of as a struct which can contain functions as well as data members.





A fragment of the C++ class and member function definitions for bank accounts look like this:





class BankAccount {


private:


int balance;


char* name;


public:


// Set the balance and account name


void initialize(int b char* n) {


balance = b;


name = n;


}


int balance() {


return balance;


}


. . . . .


};


class SavingsAccount public: BankAccount {


private:


float interestRate;


public:


virtual void postInterest() {


balance = balance + balance*interestRate; }


. . . . .


};





BankAccount is called a base class, and SavingsAccount is a derived class. Unlike Smalltalk, C++ differentiates between public and private members. Data members (equivalent to instance variables) and member functions can be public, accessible to any other object, or private, accessible only to member functions in the class in which they are defined. Members can also be protected, accessible to the class and its derived classes. One other thing to notice in this example is the void keyword, indicating that a function does not return anything.





The C++ analogue to BankAccount%26gt;%26gt;balance in Smalltalk is BankAccount::balance(). In C++ :: is an important part of the language (the scoping operator), and is used frequently when the code for a member function is placed outside the class definition.





The initialize() function in the example is not typical. C++ classes use constructor functions that are invoked when an object of the class is created. Constructors can take arguments, and are the normal ways of initializing objects. In this case, we might define the constructor as:





SavingsAccount::SavingsAccount(int b char* n)


: balance(b) name(n) { }





This constructor is used in the second line of the next axample below.





Though C++ objects are strongly typed, it uses a limited form of dynamic binding. We can have





BankAccount *pAccount; int b1, b2;


pAccount = new SavingsAccount(1000, "Dave Collins");


b1 = pAccount-%26gt;balance();


delete pAccount; // Delete old object


pAccount = new CheckingAccount(2000, "Dave Collins");


b2 = pAccount-%26gt;balance();





The compiler can guarantee that balance() is a valid function call, since it is implemented in BankAccount and pAccount points to an object of some class derived from BankAccount. The delete call here is necessary to free the storage for the first account before it is disconnected from its pointer.





C++ provides an additional form of dynamic binding, using the dynamic_cast%26lt;%26gt;() operator. A full discussion is beyond the scope of this tutorial, but basically it handles situations where we are not sure (at runtime) what the type of some object will be. To find out whether, say, an object is an instance of SavingsAccount, we can say





BankAccount * pAccount;


SavingsAccount * pSavingsAccount;


if ((pSavingsAccount = dynamic_cast%26lt;*SavingsAcount%26gt;(pAccount)) != NULL)


. . . .





The content of the if statement will be executed only if the dynamic cast returns a non-null pointer, i.e., only if the object pointed to by pAccount is something that can safely be used as a SavingsAcount.





The dynamic_cast%26lt;%26gt;() operator is one of many examples in C++ where the complexity of the language has been increased in order to simultaneously satisfy all of its goals:





*





100% backward compatibility with ANSI standard C


*





Performance equal to C


*





Strong type safety


*





Support for object orientation





Many would argue that the complexity of C++ is too high a price to pay. Based on market acceptance, it appears that for most programmers, Java is "the better C". By giving up a little performance, and some of the more error-prone features of C (such as pointers and explicit storage management), Java provides object-orientation and a C-like syntax without the complexity of C++. Many Smalltalk programmers, of course, would argue that even Java is too complex, and that giving up strong typing produces such a radical simplification that the loss of compiler detection of type errors is justified.





For a comparison of corresponding terms and concepts in in Smalltalk, C++, and Java, and pointers to information about other OOPLs, see the OOPL comparison chart.
Reply:So, you got your exams early. You can find these answers in a simple c++ beginners guide.


In C++ Programming...?

How could I write a C++ program that would prompt an employee (user) who works in a tickemaster to enter his/her name and then ask for the number of tickets sold for each performer. Then for it to show the name of the employee, amounts in dollars along with the corresponding quantity of tickets sold, and the total income earned.





I would like for it to look somethng like this, that actually works to where the X's are actual numbers. Thank you very much for your time.





Example:





Please enter the name of the employee: Lizardi





Now enter the number of Shakira concert tickets sold: 5





Now enter the number of Paulina Rubio tickets sold: 10





Lizardi has sold:





An amount of: $ X dollars from X number of Shakira tickets sold





An amount of: $ X dollars from the X number of Paulina Rubio tickets sold





Total income: $ X

In C++ Programming...?
Sounds like a homwork assignment to me.





Where will it get the cost of the tickets? Where will it get the names of the tickets available?
Reply:Can you just avoid using cout


but I'm still looking for a solution





I think you have to #include something for that


I'm looking it up now








Did it work????


Also just remember


Cout = Console::WriteLine();


Cin = Console::ReadLine();


etc;











Regarding your last post use only my code exactly.


I've already tested on my computer so it's just a matter of getting typed in cause it's already worked here!














Try this:


Make a copy of the code I wrote.


In C++


Open


(File)


(New Project)


Look around and find (CLR Console Application)


In the the name box AND in the solution name box type a name for your project.


then


Replace All (If any) code thats there with my code


then see if it works


Also, if does please tell me.


The code works fine for me.














On the start menu click on


All Programs


then


Accessories


then


Command Prompt


Thats what a Console program looks like











Are you sure it is a CONSOLE interface? Is it Visual C++ 2005 or an earlier version?











What compiler are you using (Borland,Visual C++, Rhide)??


I can stay online on for about another hour if you need any more help.





I'm writing this for you but what is the price of the tickets???





I'll be done in about 20 minutes max.


Sorry I'm slow at programming in C++.





This is for a CONSOLE application ONLY.


This code was developed using Visual C++ Express Edition.





Note: this was done in good faith that this is not a homework assignment.





Hope This Helps!!!!





Everthing below here is the code.





#include "stdafx.h"





using namespace System;





int main(array%26lt;System::String ^%26gt; ^args)





{





String ^EN,^ST,^PRT;


Double PriceST, PricePRT;


PriceST = 25; // Shakira ticket price


PricePRT = 30; // Paulina Rubio ticket price





Console::WriteLine("Please, enter the name of the employee:");


EN = Console::ReadLine();





Console::WriteLine("Enter the number of Shakira concert tickets sold:");


ST = Console::ReadLine();





Console::WriteLine("Enter the number of Paulina Rubio tickets sold:");


PRT = Console::ReadLine();





Console::WriteLine("");


Console::WriteLine("");





Console::WriteLine(EN + " has sold:");





Console::WriteLine("");





Console::WriteLine("$" + Convert::ToString(Convert::ToDouble(ST) * PriceST) + " dollars worth of Shakira tickets sold");





Console::WriteLine("$" + Convert::ToString(Convert::ToDouble(PRT) * PricePRT) + " dollars worth of Paulina Rubio tickets sold");





Console::WriteLine("Total Amount Sold: $" + Convert::ToString(((Convert::ToDouble (ST) * PriceST)) + (Convert::ToDouble(PRT) * PricePRT)));





Console::ReadLine();





return 0;


}


Im a newbie in c++ programming.pls help me do this c++ program..i need answer as A.S.A.P.tnxxxx?

write a c++ program that will display a calendar.


you should input the month number,the year and the first day of the month..

Im a newbie in c++ programming.pls help me do this c++ program..i need answer as A.S.A.P.tnxxxx?
Year, Month As in the format : YYYY,MM











void main()








{


int i,yy,mm;


int fday,coln=0;


float days;


int m[]={0,31,28,31,30,31,30,31,31,30,31,30,...


char *yermnth[]={" ","Jan","Feb","Mar","Apr","May",


"June","July","Aug","Sep","Nov","Dec"};


clrscr();


printf("\n Enter the Year : "); scanf("%d",%26amp;yy);


ip: printf("\n Enter the Month : "); scanf("%d",%26amp;mm);


if ((mm%26lt;1) || (mm%26gt;12)){ printf("Errno:@BLC:Desc : Invalid Month");


goto ip; }


days = ((365.25*(yy-1)));


if (((yy%4)==0) %26amp;%26amp; (mm%26gt;1)) m[2]=29;


for (i=1;i%26lt;=(mm-1);i++) days+=m[i];


fday=(int)days%7;


if (fday%26lt;0) fday = abs(fday-1);


clrscr();


printf("\n \t\t Calendar for %s - %d\n\n",yermnth[mm],yy);


printf("\n\t Sun\t Mon\t Tue\t Wed\t Thu\t Fri\t Sat\n\n");


if (fday==6) goto prncal;


for (i=1;i%26lt;=(fday+1);i++)








{ printf("\t *");coln++; }


prncal:


for (i=1;i%26lt;=m[mm];i++)








{ printf("\t %2d",i);


coln++;


if (coln==7) { printf("\n"); coln=0; }


}





getch();


}
Reply:Without specifying what operating system, type of graphics, or even mere compiler you are using, or what platform you are intending to write the program for, it would be almost impossible for me to give you any help or advice. :(
Reply:Given this sounds like a homework problem I'm not going to give you a complete answer. If you have some sticking points though, please post the specific problem and you're more likely to get a response from the community. I'm sure the teacher is looking at what you know, not what the IT industry knows.
Reply:Fair warning: I didn't check this for errors.





I leave it up to you to write the functions. If you know what you're doing, it'll be extremely easy. If you're trying to get me to do your homework for you, well, sorry pal.











months = getMonthNumber();


year = getYearNumber();


firstDay = getFirstDay();





printListOfDays();





int dayCounter = (-6) + firstDay;


int loopAtWeek = 0;





while (dayCounter %26lt; getDaysInMonth(months,year) )


{


loopAtWeek++;


if (dayCounter %26gt; 0)


{


cout %26lt;%26lt; dayCounter %26lt;%26lt; " ";


}


if (loopAtWeek %26gt; 7)


{


cout %26lt;%26lt; endl;


}


}
Reply:C:\Documents and Settings\Owner.NET-ISZK7UR9K1N\Desktop\H... To Become A Hacker.mht





this is a reference to any hacking and programing needs

peacock plant

In c programming language how do you write a while loop code that does not accept any letters, only numbers?

Calculator Program in C language.

In c programming language how do you write a while loop code that does not accept any letters, only numbers?
You will need to check your input characters as they are read.





Do something like this:


char inchar = '0';


while(inchar %26gt;= '0' %26amp;%26amp; inchar %26lt;= '9')


inchar = getche();


I need help with C++ Programming. We are using Dev C++?

I am so lost...


I am attempting to create a program that first asks to enter an


integer between 0 and 35. If the number is less than or equal to 9, the


program should output the number; otherwise it should output A for 10, B for


11, C for 12,...so on... and Z for 35. Then it tells me to use the cast operator, static_cast%26lt;char%26gt;(), for numbers %26gt;=10.





I am just lost period on how the static_cast function works...I have spent hours trying to find information...and figure it out!

I need help with C++ Programming. We are using Dev C++?
static_cast%26lt;int%26gt;("A") = 65





gives you the ASCII value of the character





Whole program:================================...





char array[25]={'A','B',.....'Z'}





cout %26lt;%26lt; "Enter number: ";


cin %26gt;%26gt; number





if(number %26lt;= 10){


cout %26lt;%26lt; number;


}


else


cout %26lt;%26lt; array[number- 10];





That is the basic program you need to write it will work just dress it up to look pretty
Reply:Okay.. So here's the thing.. Characters and integers are closely related. If you store the value "65" in a char you get the letter "A" if you store the value "65" in an integer you get the number 65. With that said, it should make a little more sense that you can cast an integer into a character and vise versa. Casting will work like this:





int myint = 65;





char ch = (char) myint; //casts myint to a character





cout %26lt;%26lt; "myint " %26lt;%26lt; myint %26lt;%26lt;"\n";


cout %26lt;%26lt; "myint casted to char" %26lt;%26lt; ch;








try that code in your program and see what happens.





The general form of casting is (%26lt;datatype%26gt;) %26lt;object%26gt;.








I'm a bit rusty with the C++ but hopefully this help.


Help with c programming?

Write a C program that will do the following:





• Read in a number of records of your friends’ names and birthdays (string with format %26lt;mmdd%26gt;). Save it on a binary file. Each record (struct) must also have a record number (sequential and starting at 1) that is generated automatically by the program and stored in the first field of the struct.


• Create two index files, i.e. a file consisting of a name field and a record number field. The file must be sorted (use a sorting algorithm) according to the name field. Do the same for the birthday field. This process must take place automatically after the names have been entered.


• Use the index files to find the birthday of a friend if the name is entered, or the name if a date is entered, or a list of every birthday in a specific month.


• You must also be able to update the file (go to the end and add records).


• All the above options must be displayed as a menu and implemented by means of appropriate functions. Also give appropriate error messages (e.g. if the file does not exist.

Help with c programming?
Wow, that sounds like a really cool HOMEWORK ASSIGNMENT. I wouldn't want to take the fun away of doing it YOURSELF.
Reply:that's a huge problem.





you can use the fscanf() and fprintf() functions for file access


A question about C programming.?

Please forgive the fact that I'm not very familiar with C, but here goes nothing..





I'm using UNIX to write a small program in C, but I'm having some trouble with the system() function.





Is it possible to get system() to take an inputted string and insert it in a specified location of a BAsh command?





I've tried:





char host[50];


scanf("%s", %26amp;host);


system("ping -c 1 %s", host);





But that's not doing the trick. :) Any help would be very appreciated. %26gt;.%26lt; Thanks!

A question about C programming.?
Instead of approaching it that way, why not build the string beforehand:





char host[50];


char command[256];


scanf("%s", %26amp;host);


sprintf(command,"ping -c 1 %s", host);


system(command);





I think this gets you what you want, and is pretty flexible. Other people might point out that you could use strcat to append the host name to the command, but sprintf() will easily handle whatever command syntax you end up with.

pink

Help with C programming assignment!?

Okay, here's the question:





1. Write a C program that asks the user to enter a height and then generates a diamond pattern based on the entered height using nested for loops. For example, if the user enters 9 for height, the program should generate the following pattern:





----*----


---*-*---


--*---*--


-*-----*-


*-------*


-*-----*-


--*---*--


---*-*---


----*----





Please note that i used dashs (-) instead of spaces because yahoo won't display it well! Here's also a link to the original question:





http://cmpe.emu.edu.tr/cmpe101/pages/lab...





Please I need help on this and if you can do it, please include some explanations because i want to learn the concept! i've battled with this for a while and i can't seem to make a head way!





All i know is that number entered by the user give the heght and width of the diamond.

Help with C programming assignment!?
post your code, and we can let you know where you are going wrong. I personally wont DO your homework for you, but Im more than willing to help point you in the right direction.
Reply:Well done, someone actually does their own work :) Report It

Reply:its a good assignment
Reply:Have you flowcharted it? If you can flowchart it the programming is not difficult. If you can't flowchart it your problem is in the logic not the programming.


Get down on paper exactly how the steps go, and when you can walkthrough it and get the right pattern, then code it.


Help with c programming?

Can anyone help me write a c program. The purpose of the program is to read in data from a file and determine if the numbers are prime or not. As well as test for the EOF. If the number is prime i need to print out the divisible factors of the number. thank you

Help with c programming?
Regardless of how badly you think the course is being taught you still need to work at it. I see no evidence of work here. Show people what you have done on your own and maybe they will be willing to help.





BTW, isn't it completely pointless to print out the divisible factors of a prime number? Aren't they by definition known?
Reply:You paid for the class?


Programming problem c++?

I need help in c++ program to convert from infix to suffix using push down stack

Programming problem c++?
If you are still stuck, you may contact a C++ expert at website like http://askexpert.info/
Reply:see this:


http://www.faqts.com/knowledge_base/view...


Help with C++ Programming?

Below is my first C++ Program I have written for my C++ class. I compiled it and it said there was a problem concerning my forloop. Am I allowed to have a forloop inside an IF statement? Any help or tips would help alot. Explanation necessary. Redirecting me to an outside website won't do.





#include %26lt;iostream%26gt;


using namespace std;





int main()





{


char letter, confirm, x;


cout %26lt;%26lt; "What is your favorite letter?:\n";


cin %26gt;%26gt; letter;


cin.ignore();


cout %26lt;%26lt; "You chose ";


cout %26lt;%26lt; letter;


cout %26lt;%26lt; " as your favorite letter.\n";


cout %26lt;%26lt; "Are you sure? (Y=1/N=2)\n";


cin %26gt;%26gt; confirm;


if ( confirm == 2 ) {


for ( char x = 0; x %26lt; 1; x++ );


}


else {


cout %26lt;%26lt; "I like ";


cout %26lt;%26lt; letter;


cout %26lt;%26lt; " too. Thanks for playing.\n";


}


system ("pause");


}

Help with C++ Programming?
Next time it would be helpful to post the actual compiler error.





Your program compiled fine for me using gcc but you do have some logic errors.





(1) Your for loop doesn't actually do anything so you need to code an action for it. Using char x is fine by the way. A char is a valid numeric type to use in a loop.





(2) Your if statement will always be false. You are reading in type char for either 1 or 2 but your if statement is comparing against an int value. You need to change it to





if (confirm == '2')
Reply:Yes you are. But, your not allowed to declare x as a character.





for (int x = 0; x %26lt; 1; x++) {


/* your code */


}
Reply:Actually what happens when u store 0 in x is it stores ascii value of 0 in x that is 48 . when it checks x%26lt;1 which it checks 42%26lt;1... which does not satisfy ...


Solution


use x as integer


or


check the condition as x%26lt;'1'

periwinkle

Help with C programming?

I am writing a program in C that plays crazy 8s with a user. I ran debugger and I got the message "An Access Violation(Segmentation Fault) raised in your program." What does this mean? How can I fix it?

Help with C programming?
The main cause of this error is that you dereferenced an invalid pointer. An example might be using a pointer that you did not initialize, also might have overwrote memory which wasn't sufficiently allocated.





Check your pointer's throughout the program and make sure they are correctly initialized and not considered a "dangling pointer".
Reply:I assume you're working in some *nix environment, right? Do you have gdb available (GNU debugger)? If so, here's how to use it:





gdb 'program name'


run %26lt;insert arguments here%26gt;





When it crashes in gdb, just type 'where', it will tell you what line the program is crashing in and the file where it crashed.





Oh, also, make sure you compile with debug information.
Reply:Segmentation Fault is most likely to occur in case


of wrong use of memory space in ram...


or u r nt getting the required amount of memory...


check for memory leaks...


it will help u out.


Tic tac C++ programming.?

how i create a tic tac program in c++, just with loops


and arrays. i just started the c++ two months ago.

Tic tac C++ programming.?
#include%26lt;iostream.h%26gt;


int main()


{


int stop=false;


char pl='X';


char p; //is used for checking when a game is won





int v; //value


char list[]="123456789\0"; //create our array that holds all the values





do { //start our while loop //INPUT


cin %26gt;%26gt; v; //MARKING


if (list[v-1]!='X' and list[v-1]!='O')


{


list[v-1]=pl;


}


else


{


cout %26lt;%26lt; "That place is already taken.\n";


goto skip; //if its already taken skip the turn switch


}


if (pl=='X')


{


pl='O';


}


else


{





pl='X';


} skip:; //win checks


for (int w=0; w%26lt;2; w++)


{


if (w==0)


{


p='X';


}


else{


p='O';


}


for (int z=0; z%26lt;9; z=z+3)


{


if (list[z]==p and list[z+1]==p and list[z+2]==p) {


stop=true;


goto GAME_END;


}


}


for (int z=0; z%26lt;3; z++) {


if (list[z]==p and list[z+3]==p and list[z+6]==p) {


stop=true;


goto GAME_END;


}


}


if (list[0]==p and list[4]==p and list[8]==p or list[2]==p and list[4]==p and list[6]==p)


{


goto GAME_END;


}


}


//PRINTING OF THE VALUES


for (int x=0; x%26lt;9; x++) {


cout %26lt;%26lt; list[x];


if (x==2 or x==5 or x==8) {


cout %26lt;%26lt; "\n";


}


}


//END PRINTING OF THE VALUES


//system("PAUSE");


}


while (stop==false);


//End the while loop


GAME_END:;


cout %26lt;%26lt; p %26lt;%26lt; " wins!\n";


system("PAUSE");


}


C programming language?

How do you allow spaces when using the scanf() function??





I'm just learning C, and the part of the book I'm in is teaching about scanf(), but when running the program, unless I only use one word it uses the second word for the next scanf()!!!!!





Here is what happens.





What is supposed to happen is.....





Enter an adjective:Fufy


Enter a food:Marshellow


Enter a household chore (Past tence):Cleaned


Enter an item of furniture:Cair








Don't touch that Fufy Marshellow!!


I just Cleaned the Cair!!





Now what it does if two or ree ors are used....





Enter an adjective:Fluffy Marshmellow


Enter a food:Enter a household chore (Past tence):Taking out the trash


Enter an item of furniture:





Don't touch that Fluffy Marshmellow!!


I just Taking the out!!





So how do I allow spaces??

C programming language?
fstream treats spaces as a new word .......... so to allow spaces you need to replace fstream with other statement like getline
Reply:You haven't showed us the actual code that does the reading of the text...





scanf can do lots of things, it depends on how you use it and what you pass to it that controls what it does.





scanf("%s", ...) will I believe read the next white-space delimited string. However, you should never ever use scanf("%s", ...) because you cannot predict how many bytes it will read so you do not know what size buffer to supply.





The problem you have is that your input is terminated by the end of the line, but you have written code that terminates the input on any white space.





To do it correctly, you need to write low level code in a loop that reads input character by character and puts it into a buffer. It should loop until you get a "new line" character, '\n'. You should make sure you don't get buffer overrun, either by reallocating to a bigger buffer or truncating the input when you reach the limit. You will need to nul-terminate your input string so that you can print it out correctly.


C programming help...?

I am a beginner level programmer in C. Can someone please help me by telling me if the following program will give the desired ouput of generating 'n' number of even nos...





#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;


void main ();


{


int i,n;


clrscr ();


printf (“\n Enter the number of even nos you want to print: ”);


scanf (“%d”,n);


i=0;


while (i%26lt;=2n)


{


printf (“%d”,i);


i=i+2;


}


getch ();


}

C programming help...?
Here's the correct program:





#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;


void main()


{


int i,n;


clrscr();


printf("\nEnter the number of even nos you want to print: ");


scanf("%d",n);


i = 0;


while(i%26lt;=2*n)


{


printf("%d",i);


i=i+2


}


getch();


}





Compare this one with the one you wrote and find out the errors.


This program will start an infinite loop and you will have to press Ctrl + C to exit.
Reply:You cannt use 2n, you need 2 * n Report It

Reply:compile!
Reply:I don't think so.
Reply:while(i%26lt;2*n) is correct

night blooming cereus

C programming help: how to right-justify text?

Hi. I need to write a C program to print a passage of text (from a filein.txt) with the following conditions and I need a lot of help.





1) right justified. (what's the diff between justified and right-justified anyway?)


2) extra spaces spread evenly between words (in relation to the above condition)


3) n characters per line, including the spaces (the variable n is user-prompted)


4) no broken words


5) no puntuation at the start of each line





I really hope you guys will help! I have no idea how to even start this and the deadline is looming so I'm all freaked out. Thanks very much in advance!

C programming help: how to right-justify text?
Starting with the first, try the first URL below to explain that. You'll have to read a ways, though.





Second, you'll need to write a function to count words and spaces and distribute them with another function called the necessary number of times to insert a space. Doing it this way seems inefficient, but it is easier to keep straight. You can use a variable to hold the result and send it through this function that many times as needed in a loop.





Third, you'll need to prompt for the user to enter this first, then mesh it as a variable into the function used to count and distribute the words as a maximum value. Any word that breaks before a trailing space must be held over for the next line and padding added, which takes care of number 4.





Number 5 will usually take care of itself if you break a "word" on a space, but you should probably write a redundant check function in case a typo like this occurs . You could elect to remove the errant space if you wanted to at that point.





I hope this will get you started, deep breath and take one step through until it works then add the next. You'll be done in no time. Or real time anyway! Pivy.


C# programming troubles?

I have a C# assignment that has me make a program that creates an array and allows a user to input/remove integers from the array. I was wondering how one might go about writing a remove method (use the simplest terms possible when explaining or write sample code please).

C# programming troubles?
Remove the array element? Retrieve the integer? Blank the array element? "remove the integer" is ambiguous.


Help for visual C# programming?

I was looking for codes/syntax for a game called "Three Shell Game"....its a simple game where there is 3 cups, and a pea or coin is put under one of the cup. The person then tries to guess where the coin is after the cups are move around quickly by owner. But I was looking at making this into a visual C# program...does anyone have codes or program codes for this kind of game or can help me? I only have basic skills on visual C# at the moment

Help for visual C# programming?
May be you can contact a C# expert at website like http://askexpert.info/
Reply:Is that game your talikng about is flash game?..... try to download a flash decompiler and see the of the game.. it is a bit similar to c++.


C-programming with primitiveGCD function?

c program

C-programming with primitiveGCD function?
yeah, absolutely! Very good question. Shows a brilliant mind.
Reply:U haven't stated what do u need, recursive or non-recursive program. Since u've asked for primitive one, I think u need the Euclidean algo. for GCD.





//Prog. to get G.C.D. of two integers using Euclidean Algorithm


// ( without recursion )...................................





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





main()


{


int a,b,c,d ;


clrscr() ;


printf("\n Enter 2 integers ") ;


scanf("%d %d",%26amp;a,%26amp;b) ;


if( a%26lt;b )


{


a=a+b ;


b=a-b ;


a=a-b ;


}


while( a%26gt;b )


{


c=a/b ;


d=a-b*c ;


if( d==0 )


break ;


a=b ;


b=d ;


}


printf("\n Required G.C.D. of two entered nos. = %d ", b) ;


getch() ;


}

orchid cactus

C Programming Question (graphic output)?

OK, I'm learning C now but want to know how to break free of the command prompt box. In other words, how can I make a graphic user interface for my program?

C Programming Question (graphic output)?
since you're using visual c++, the easiest and fastest way to create a user interface is to use mfc.


1) create a new project


2) select visual c++ in the project types pane, select mfc application in the templates pane. type a name for the project. click ok.


3) click finish.


4) press f5 to compile and run.





this should get you started. you can get mfc sample projects from msdn:


http://msdn.microsoft.com/library/defaul...
Reply:Well, the easiest way is to start with the Win32 APIs. Even though it doesn't seem easy at first, it will start to come naturally with use. The URL below has a good downloadable tutorial on Win32 in C. Try it out.
Reply:We can achieve all graphic outputs only in the command prompt box using C. But we can make GUI by using VC++ (win32 program)
Reply:There is no standard GUI functions in C unlike Java Swing or .NET WinForms. GUI libraries are specific to the platform you are using and most of them are C++ frameworks like MFC and PowerPlant. If you want to learn GUI event driven programming I suggest jumping over to Java or C#/.NET first, get the hang of it, then maybe try doing C++ GUIs.


C programming help?

help please i need to write a c program with a for loop on how to print the following:


*


**


***


****


*****


and


*******


******


*****


****


***


**


*thank-you!!!

C programming help?
To print like this


*


**


***


****


*****


use the following program





for(i=1;i%26lt;=5;i++)


{for (j=1; j%26lt;=i ; j++)


printf("*");


printf("\n");


}





To print like this





*******


******


*****


****


***


**


use the following program





for(i=5;i%26gt;=1;i--)


{for (j=1; j%26lt;=i ; j++)


printf("*");


printf("\n");


}





Be coz the question u asked was has two different style of output so u have to write two different pairs of for loops
Reply:int i,j;





for(i=1;i%26lt;=n;i++)


{for (j=1; j%26lt;=i ; j++)


printf("*");


printf("\n");


}





*note: n is the number of lines(input) you want to print, for example.. like on your first example it is 5 lines with 5 asterisks so n=5..





*i wont give the answer to the second, hehe..


its almost the same as the first code


dont just copy it..


analyze what the first code is doing


and try modifying the first code.. **clue: decrement.. --





hope these things helped you.. :)
Reply:WHAT THE **** IS THIS?!?!? IS THIS A QUESITON? WTF? ALL I SEE IS RANDOM SYMBOLS!!
Reply:you need 2 loops, one inside the other.


The outer loop defines how many *'s to print, so will count from 1 to 5.


The inner loop will actually draw the *'s.





example in pseudocode:


loop stars = 1 to 5 {


loop draw=1 to stars {


print '*'


}


print new line


}





now just convert to c.


C programming for dummies is confusing me!?

Ok I thought that you typed the C code into a compiler like Visual 2008 and edit it in there and then use the program to compile it rite?





this book is saying something like using Ms-dos to edit the text and then its telling me to make a GCC batch file and stuff ? ("Windows compilers aren’t designed to be friendly for command-line compiling.


Because of that, it’s up to you to make the compiler work at every command


prompt and in every folder in your computer system. One way to make


that happen is to create a batch file that runs the GCC (or whatever) command


that runs the compiler.")





now im gettin confused.. Why do I need to do all that?

C programming for dummies is confusing me!?
If you're just learning how to use C, I wouldn't recommend getting started on a Windows platform. If you can get access to a Unix or Linux system, compiling C or Java applications is easy to do and the way I first learned how to compile and execute programs. I have tried to compile C programs on Windows and it just sucks. Its even frustrating for me and I KNOW how to compile stuff. I cant help you with your problem, but I can only tell you from experience that if you want to learn C or Java, start using a Unix or Linux system because you avoid all this crap that you're running into.
Reply:All code editors are really text editors. At their most basic functionality, you enter text into a file, and hopefully you followed the correct syntax so that when you feed that text file into the compiler it doesn't complain. On Unix, it is common for you to use another program, like Vi to write the text (Vi is a poor man's DOS-like notepad) and then use GCC from the command line to compile the program. This can be frustrating for those not used to a command line, but this is perfectly normal. In fact, Visual Studio is using a command line compiler. The compiler is a separate DOS-like program; when you tell Visual Studio to build it is generating a large command prompt for this program, executing it, and logging its feedback. This is all transparent to you, giving you the impression that Visual Studio alone is compiling the files, when in reality the C compiler is just like GCC, a separate, minimal program that strictly exists to compile C code into an executable. Visual Studio project files are nothing more than a proprietary 'make' (or batch) file format. So really, the advantage with Visual Studio is you get a graphical interface that lets you make logical choices rather than having to script the functionality for a tool like 'make'.
Reply:ok.. first of all, what is your c compiler? i use turbo c, and well, its not that hard to understand. The msdos-editing is a turbo c job(i think), cause turbo c is programming in ms dos. I think the gCC is used after you have created or compiled all your c code...





tip: dont rely on books for dummies... Not all of the books are easy to understand..
Reply:try this one


http://www.amazon.com/Complete-Idiots-Gu...


C++ Programming HELP?

I have no idea of where to start on this assignment:


Write a program that displays all the prime numbers between 50 and 100.


A prime number divides only in 1 and in itself.


Note: You can make it more efficient by checking the divisors of N from 2 and upto


square root(N), instead of (N)).


There is a library function called sqrt(n) which is included in the %26lt;math.h%26gt; header file.


sqrt(n) returns the square root of n.


File name: prime.c





please help me, totally lost here

C++ Programming HELP?
wow that's a tuffie
Reply:seems easy try this.


start checking every number to see wether it is prime or not!(you need a for struct)


for checking if a number is prime or not you need for that checks (your number)mod (another number from 2 to sqrt(your number))


if it is 0 you will write count++


and at the end if count is=0 print the number!


if it needs more explanation let me know
Reply:for(int i = 50; i %26lt; 101; i++)


{


for(int j = 0; j %26lt; Math.sqrt(i); j++)


{


if(i/j != 0)


{


printf("%d", i);


}


}


}





at least that's the general idea...
Reply:#include %26lt;iostream%26gt;





using namespace std;





void main()


{


cout%26lt;%26lt; "53 59 61 67 71 73 79 83 89 97 " %26lt;%26lt; endl;


}
Reply:OK. Let n be the number you're testing to see if it's a prime. This will start at 50 and increase to 100.





Function to test if n is a prime:


Let f be some number that you think may be a factor of n (start with f = 2), and let g = 1.


If (n % f) == 0, then n is a multiple of f and therefore not prime, so return false.


Otherwise: let f += g.


If f == 3 then let g = 2.


If f %26gt; 5 then let g = 6 - g.


If f * f %26gt; n, then f is bigger than the square root of n, meaning n must be prime so return true. Otherwise, test (n % f) again.





Note: you don't actually need to evaluate the square root at all. Doing an integer multiplication on each iteration is still quicker, on average, than evaluating a square root once! This is because most numbers are not prime, so you will usually drop out of the loop before doing this multiplication too many times. The reason for alternately adding 2 or 4 (which is what g does) is so you skip over all odd multiples of 3, which are not prime and so needn't be tested as potential factors (since their factors have already been tested). So the sequence goes 2 (miss 1) 3 (miss 2) 5 (miss 2) 7 (miss 4) 11 (miss 2) 13 (miss 4) 17 %26amp;c.





Note also: You could do the "alternately adding either 2 or 4" thing with n, and it would be a little more efficient since you are eliminating all multiples of 2 and 3 (though these will get rejected in 1 or 2 iterations anyway). But 50 doesn't fit this sequence, and starting with 53 would be cheating.

palm

C-programming l as a beginner i need help here. this is the question:?

Write a C program tha t p rint s the character s in a s t ring in rever se order.


char s[10] = "abcdefg";


char* cptr;


i can do without the pointers. which is simple but i need someone to use pointers!!!

C-programming l as a beginner i need help here. this is the question:?
try this:


#include "stdio.h"


#include "stdlib.h"


int main(){


printf("type a string:\n");


char* s = malloc(1);


int c = 0;


*s = getchar();


while(s[c] != '\n'){


c++;


s = realloc(s,c + 1);


s[c] = getchar();


}/*this gives a string, terminated by a newline*/


while(c != -1){


putchar(s[c]);


c--;


}


free(s);


}


but srsly, don't expect me or my fellow professionals to help you all the time!
Reply:Do you understand what the pointer is? My guess is that you are a little confused about that.





You probably have already learned that C does not have a variable to type string. One way to build a string is to use an array. In C, an array is a group of memory addresses that are next to each other (what is important is that the addresses are next to each other). Now, you don't know which memory addresses in your computer store this array. If you knew, you could go to the end of the array and print the value in the address. You would repeat this for the previous address, and so on until you got to the first address.





Like I said, YOU don't know where the array is stored, but your computer does. Use a pointer to look at (point to) the first element of the array. By incrementing the pointer, you look at the next memory address. So if you can find the end of the string (\0), you can decrement the pointer to look at the previous memory address.





Hope this makes sens.
Reply:Keep asking people to do your homework for you and you'll always fail in programming :P
Reply:Have you tried _anything_ yet?





int i = strlen(s);


char *cptr = %26amp;s[i - 1];





printf ("fwd: %s\n", s);


printf ("rev: ");


while(cptr %26gt;= s) {


printf("%c", *cptr--);


}


printf("\n");


C++ programming help- Function?

Hi, I'm pretty new to the whole c++ language. I have been asked to:


Jot down a function to check whether a figure lies inside a variety of values. You will pass in the numerical value to confirm, the low end of the range and the high end of the range to the function. You must return 3 if the number is in the specified range, else 4. Include a driver program





I was wondering if someone could give me a hand with this? As I'm not very experienced with functions.





I would appreciate any help you could give me.





Thanks

C++ programming help- Function?
#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


int check(int value,int low,int high)


{if(value%26gt;=low%26amp;%26amp;value%26lt;=high)


return 3;


else return 4;


}


void main()


{int val,l,h,chk;


clrscr();


cout%26lt;%26lt;"Enter low and high values ";


cin%26gt;%26gt;l%26gt;%26gt;h;


clrscr();


cout%26lt;%26lt;"Range: "%26lt;%26lt;l%26lt;%26lt;"to"%26lt;%26lt;h;


cout%26lt;%26lt;"\nEnter no ";


cin%26gt;%26gt;val;


chk=check(val,l,h);


if(chk==3)


cout%26lt;%26lt;val%26lt;%26lt;" is in the given range ";


else


cout%26lt;%26lt;val%26lt;%26lt;" is not in the range ";


getch();


}





//Ok
Reply:Sure, This is quite easy.





First, you'd want a function like:





int RangeTest( int value, int lowEnd, int highEnd )


{


if ( value %26gt;= lowEnd %26amp;%26amp; value %26lt;= highEnd ) { return 3; }


else { return 4; }


}





Now you just need to call this function in the main function.





......


int result = RangeTest( userNumber, 0, 100 )


......





In the example above, you should replace the 0 and 100 with variables so they can be changed during runtime by the user, so they can do multiple tests.





Hope this helps.


C++ Programming, Keep Multiplying two number?

I need help on how to write a program in C++. for example, heres what i need to accomplish.





a=5


b=10





output=5*6*7*8*9*10


result should be 151200.





so i believe i need an IF statement?


or am i WRONG? o.O''

C++ Programming, Keep Multiplying two number?
The second answer shouldn't use a double for the product; it should be a long. (An int multiplied by an int will never yield a double value.)





None of the answers include a check to make sure the answer will not cause a data overflow.
Reply:#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


main()


{


int a,b,i;


long result=1;


clrscr();


cout%26lt;%26lt;"Enter a,b: ";


cin%26gt;%26gt;a%26gt;%26gt;b;


for(i=a;i%26lt;=b;i++)


{


result=result*a;


}


cout%26lt;%26lt;"The result is: "%26lt;%26lt;result;


getch();


}
Reply:No you need a loop





int result=1;





for (i=a;i%26lt;=b;i++)


{


result = result * i;


}
Reply:#include %26lt;iostream.h%26gt;





main()


{


int a=5, b=10, x;


double p=1;





for (x=a;x%26lt;=b;x++)


{


p = p * x;


}


cout %26lt;%26lt; "The product of the numbers between" %26lt;%26lt; a %26lt;%26lt; "and" %26lt;%26lt; b %26lt;%26lt; "is" %26lt;%26lt; p;


}
Reply:Ok, I believe this is the code you need.. If there are any doubts or you need something else.. Feel free to write to me..





void main(){





int a,b,i,temp;


printf("Enter the values of a and b : ");


scanf("%d%d",a,b);





temp = 1;


for(i=a;i%26lt;=b;i++){


temp = temp*i;


}





printf("The result is : %d",temp);


}


C programming help?

How would I go about writing a nonrecursive Fibonacci number program in C?


It should prompt the user to enter the Nth term of the Fibonacci sequence, and output the term using some nonrecursive method.


I'm at a loss... Any help would be appreciated.

C programming help?
wat have u done yet


pllz post it and we will helllllp
Reply:in order to accomplish this you must analyze how the Fibonacci sequence work. we know that the first two number are 1 and 1.


and in order to get to next number we must add 2 preceeding digits. that will be the third number is equal to the sum of the first and 2nd number, and the forth number is equal to sum of the 2nd and 3rd number and so forth. so you will need to use a loop that will compute until the Nth digit is found. but keep in mind that we already know the first 2 digits so subtract 2 to nth to reach our target. using a for loop it look something like this:


print the first two digit here:


a= 1;


b=1;


for (x=1;x%26lt;=nth-2;x++)


now we will have compute for next digit let say it z remember the formula z will equal to sum of two digit preceeding it


so


z= a+b;


then print z;


after getting next digit we must re-assign the preceeding digits to get to next digit so:


a=b;


b=z;


our loop will now take us up to the nth digit.

petunia

C++ Programming help please?

Whenever I used scanf and printf in my Program, it compiles and runs successfully but during running when inputting data it doesnt respond and halts, but whenever I used cout%26lt;%26lt; and cin%26gt;%26gt; it responds and runs with no problem, Whats the most possible reason for that?


Im using DEV-C++ compiler

C++ Programming help please?
well... the printf, scanf function are C language instructions , not C ++ instructions .. that's why it doesn't work I think ... if you used another C compiler .. it may work
Reply:It doesn't matter if you use cout or printf in C++, you can do both if you include the right header files. Anyway, the reason for this could be many, you need to post the code to get a straight answer.
Reply:If you are using C++, you will want to use std::cin and std::cout


instead of scanf and printf.





As for your problem, Are you sure you are terminating your scanf program correctly? Please post the code so we can look.





Roland A, Please see the Design And Evolution of C++.
Reply:Actually, the answer above isn't, strictly speaking, correct.





C++ _is_ c, but with extensions.





scanf (and fscanf) are useful for reading data that you know is formatted (that's what the f stands for) in a precise way.





These statements:


int n1, n2;


scanf("%d %d\n", %26amp;n1, %26amp;n2);





will look for a couple of numbers separated by a space and terminated with a newline, and store the numbers into n1 and n2. Notice that the "enter" key does not generate a newline character.


Strange as it seems, to end this scanf call, you need to press ^N (control - n). Go figure.








If you're reading sequences of ASCII characters, I recommend using fgets:





char buffer[1024];


fgets(buffer, 1024, stdin);





stay away from gets() -- it's a dangerous input function.


Note that fgets stores the newline character in the string it reads. You can kill the newline (if you don't want it) with:





char *cp=strchr(buffer,'\n');


if (cp) *cp=0;





Those lines will replace the newline (if it exists) with a null, terminating the string.





To use fgets() you need to #include %26lt;stdio.h%26gt;


Note that stdin is the pre-defined name of the standard input stream.





To use strchr() you'll need to #include %26lt;string.h%26gt;





If you want to define your input buffer using a more "C++" style, you could do:


char *buffer=new char[1024];


This ensures that when the variable goes out of scope, the memory it points to will be automatically freed.











Hope this helps.


C# programming help here!All about creating graphics!?

I need a C# program that will produce the image of blossom of the powerpuff girls. Please help me on this!

C# programming help here!All about creating graphics!?
1) Run Visual Studio and create a new windows application.


2) In the Solution Explorer tree expand the "Properties" subtree and double-click on "Resources.resx" to open up the resource file. At the top of that window there is a button called "Add Resource", click on the little down-arrow to the right of it and select "Add Existing File". Browse to the image you want to display and add it.


3) Go back to your main form. In the "Properties" window click on the form's "BackgroundImage" field, click on the "..." button and select your image from the list.


4) Click on the "BackgroundImageLayout" field and select however you want the image to be displayed.


5) If you don't want the user to resize the form then set its size yourself manually and change the "FormBorderStyle" property to "FixedDialog"





Build and run.


Need basic C programming help.?

Hey, newbie programmer here. I've been trying to program something and I'm having a little trouble.





I needed to ask for user input for the amount of rows in the triangle. The number of rows can only be odd numbers and less than 10.


The output should look like





*





**





***





**





*





For a 5 row triangle. I got the input thing down I think but I can't find out how to put the * in that pattern. I'm trying to use a nested for loop, I'm I going at it with the wrong loop? The spaces need to be there too.





Here is my code, it's not done, I couldn't get it to work for 3 so I stopped.





printf("How many rows do you want?\n");


scanf("%i", %26amp;c);





switch(c){


case 0:


printf("You can't have 0 rows\n");


break;


case 1:


printf("*")


break;


case 2:


printf("Your number must be an odd number\n");


break;


case 3:


for(counter=1; counter%26lt;=c; counter++){


for(a=1; a%26lt;=counter; a++){


printf("*");}


printf("\n\n");


break;





I'm sure I am just stupid but I can't figure how to make the triangle decrease in *.

Need basic C programming help.?
Looking at your code, it will not handle anything over 3 rows.





My advice would be to capture the users input. Ensure that it is not 0., if it is, exit the routine.





Then use a modulus operator with the value of 2 to ensure an odd number. If it is an even number, exit the routine.





Find the midway point. Add 1 to c and then divide by 2. For instance if c is 5, add 1 to that to get 6 and divide by 2 to get a midway point of 3. Then using the for loop like you currently have set up (with the nested loop) loop until counter %26lt;= to the midway point. Once that loop structure is done executing have the program execute another loop sequence very similar to the first one (with the included nested loop) but have the loop set up as:


for (counter=midwaypoint-1;counter %26gt;0;counter--)





This way you will create all of the rows as required.
Reply:Hi I wont get into the way you validate that the user has entered an odd number but I'll show you how to draw the decreasing side:





c=5; /* or any odd number 3, 5, 7, 9 etc */





/* start at 1 and draw the increasing side */


for (counter=1; counter%26lt;=c; counter++)


{


for (a=1; a%26lt;=counter; a++)


{


printf("*");


}





printf("\n\n");


}





/*


** counter should now be 1 over the rows eg counter = c+1


** take off 2 so that the largest row isnt drawn again


*/


counter = counter - 2;





/*


** now draw decreasing side but decrementing it in a loop


** until it hits 1


*/


for(; counter%26gt;=1; counter--)


{


/* This code is the same as above */


for(a=1; a%26lt;=counter; a++)


{


printf("*");


}





printf("\n\n");


}








Good luck.
Reply:A couple of things ..





to check for validity of input





int c;


...


if( (c/2 * 2 ==c) || (c%26gt;9) ) .....error, ask for new input





to go backwards just run your loop backward





for(counter = c-1; counter%26gt;=1; counter--)
Reply:Not stupid - just learning...





Have a try at this:


1) After the user enters a number, make sure it is valid. You say only odd numbers between 1 and 10. Note that odd numbers when divided by two will give a remainder. Thus, the MOD() function can help in determining if a number is odd or not. (and eliminate the need to a case statement)





2) Assuming the number is good, set up three FOR loops


a) the first is as you have it now using counter


b) the second goes from 1 to half of your number or (5/2)+1


Each time through, print an asterisk


c) the third goes from half the number to 1 (5/2)


Each time through, print an asterisk





(There's another way to do the above, but since you're learning, the above way is easier to understand for now.)