473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

i dont know what wrong with program..please help me

this information i put in data.txt
11221 MOHD IRFAN 80 70
11222 NURUL FITRAH 80 90
11223 MOHD FARHAN 70 80
11224 WAFFIN WARDAH 80 60
11225 SYAMSUL 50 50
99999 TAMAT 0 0

Expand|Select|Wrap|Line Numbers
  1. #include<fstream.h>
  2. #include<iostream.h>
  3. #include<stdlib.h>
  4.  
  5. main()
  6. {
  7. char nama[20];
  8. double matrik;
  9. int markah1,markah2;
  10. char gred;
  11. ifstream Fail_input("data.txt");
  12.  
  13. if (Fail_input==NULL)
  14. {
  15. cout<<"Tidak dapat dibuka untuk output";
  16. exit(1);
  17. }
  18.  
  19. cout<<" No Matrik "<<"Nama "<<" Gred "<<endl;
  20.  
  21. do
  22. {
  23. Fail_input>>matrik>>nama>>gred;
  24.  
  25. if ((markah1 + markah2)/2>90)
  26. gred='A';
  27. else if ((markah1+markah2)/2>70)
  28. gred='B';
  29. else if((markah1+ markah2)/2>50)
  30. gred='C';
  31. else gred='F';
  32.  
  33. Fail_input>>matrik>>nama>>markah1>>markah2;
  34.  
  35.  
  36. }while (matrik !=99999) ;
  37.  
when i run this program, data from data.txt cannot out...
thi give some error...
i dont know how to solve
Oct 16 '09 #1
2 2033
donbock
2,426 Expert 2GB
@sailormoon
You will get better assistance if you make it easier to help you.
What error did you get?
Did the error occur when you compiled your program or when you ran it?
If your program produced the wrong output, then please describe the output you got and how it differs from what you expected.

By the way, your source code is easier to read if you enclose it in CODE tags by highlighting the source code and then pressing the "#" button at the top of the Message window.
Oct 16 '09 #2
newb16
687 512MB
You don't print anything - you only read data from file. Then note that string input will be read until the first whitespace - so your names will be read only in half, and then the number will be expected.
Oct 16 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
9
by: aamircheema | last post by:
Hi, I have written a program (my first big program in c++). When I run the program it gives segmentation fault but when i use a printf statement to debug the program, it runs normally. I am very...
4
by: ryann18 | last post by:
What is wrong with this?? Here are the two classes...SandBox and KittyKitty?? I need to also know what happens if two or more values are equal and if exactly two values are equal, does it matter...
5
by: cppquest | last post by:
Hi all, I am doing something terrible wrong, but I dont understand why! Maybe I am sitting too long in front of this box! This is a breakdown of some code: #include <map> class MyMap :...
1
by: me001 | last post by:
i know this is set up wrong but i didnt know how to do that--sorry. but this is my program that i have. it compiles and runs, but the values are completely wrong! can anyone help me?? #include...
2
by: Tiruak | last post by:
Hi there. Thanks in advance for the people reading and trying to help. I'm very begginer using flash and action script, and I tryed to do this one navigation menu. Since I dont have experience...
8
by: mohammaditraders | last post by:
#include <iostream.h> #include <stdlib.h> #include <conio.h> #include <string.h> class Matrix { private : int numRows, numCols ; int elements ;
7
by: PetterL | last post by:
I have a setting called My.settings.firstrun set to True, set in the setting manager. When i read this in the first form form_Load in a IF sentence it always come out as false. I have tried to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.