GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-Aug-2006, 14:51
doom2006 doom2006 is offline
Awaiting Email Confirmation
 
Join Date: Aug 2006
Posts: 12
doom2006 is on a distinguished road

Expected constructor, destructor, or type conversion before "int"


im just learning how to programm in C++ and im struggling on this. (look below)

CPP / C++ / C Code:
#include <iostream> 
#include <string>
#include <sstream>
using namespace std;

init()
int 1
int 2
int 3
int 4



int main()
{

string mystr;
float total=0.00;

cout << "Enter Number " >>
getline (cin,mystr) >> int 1;

cout << "Enter Number " >>
getline (cin,mystr) >> int 2;


cout << "Enter Number " >>
getline (cin,mystr) >> int 3;

cout << "Enter Number " >>
getline (cin,mystr) >> int 4;

cout << "Total " << int1+int2+int3+int4 << /n;
return 0;
}

but i dont know what is rong here are the errors.

Code:
expected constructor, destructor, or type conversion before "int" (line 7) expected `,' or `;' before "int" (line 7)

there is somthing rong with "int a" but i dont know, please help me

Thanks
DOOM
Last edited by admin : 23-Aug-2006 at 17:02. Reason: Please insert your C code between [cpp] & [/cpp] tags
  #2  
Old 23-Aug-2006, 16:32
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Simple Problem - Help


Quote:
Originally Posted by doom2006
im just learning how to programm in C++

I respectfully suggest you get a book or refer to some on-line tutorial. Work through some examples before starting your own stuff:

CPP / C++ / C Code:
#include <iostream>

using namespace std;

int main()
{

    int int1, int2, int3, int4;

    float total;

    cout << "Enter Number ";
    cin >> int1;

    cout << "Enter Number ";
    cin >> int2;

    cout << "Enter Number ";
    cin >> int3;

    cout << "Enter Number ";
    cin >> int4;

    total = (int1 + int2 + int3 + int4);

    cout << "Total   = " << total << endl;
    cout << "Average = " << total / 4.0 << endl;
         
    return 0;
}

Output:

Code:
Enter Number 7 Enter Number 6 Enter Number 5 Enter Number 4 Total = 22 Average = 5.5

Regards,

Dave
  #3  
Old 23-Aug-2006, 16:50
doom2006 doom2006 is offline
Awaiting Email Confirmation
 
Join Date: Aug 2006
Posts: 12
doom2006 is on a distinguished road

Re: Simple Problem - Help


thanks, how did you learn, and could you recomend me to online tutorial, i would be very greatful
  #4  
Old 23-Aug-2006, 17:57
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Simple Problem - Help


Quote:
Originally Posted by doom2006
could you recomend me to online tutorial, i would be very greatful

I hope someone here can recommend some beginning level on-line tutorials that are good (helpful). Unfortunately I don't have any recent experience with specific ones.

In the beginning I learned mostly from books and learned to extend the book examples for things that I was mostly interested in (numerical analysis was one of my first areas of emphasis).

When I got around to the C language, I already had a fair amount of FORTRAN experience, so my original C training came from a single book, "The C Programming Language" by Kernighan and Ritchie. Because of numerous comments by people whose opinions I generally respect, I hesitate to recommend that to people with absolutely no programming background (although I happen to think it's just as good as anything else I have seen for a serious beginner).

There have been numerous threads on this forum that have had lots of good recommendations for books and links to on-line tutorials. I hope some of the contributers (new guys too) will chime in on this.

Regards,

Dave
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 10:09
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
URL problem in simple Content Management System dave MySQL / PHP Forum 5 21-Jul-2005 00:39
c simple question problem with switch case if13121 C Programming Language 2 25-Oct-2004 01:06
RE: A simple update and } problem Dagma20 MySQL / PHP Forum 3 27-Mar-2004 16:37

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:16.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.