| | |
warning:no newline at end of file
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2004
Posts: 3
Reputation:
Solved Threads: 0
hi,
this is the code:
#include <stdio.h>
main()
{
int m1, m2, m3, m4, m5, per;
printf("Enter marks in five subjects\n");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
per=(m1+m2+m3+m4+m5)/5;
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");
}
this is the output for:
[root@localhost lbin]# gcc -o division division.c
division.c:30:1: warning: no newline at end of file
The executable file division is runing successfully,just i want to know why there is the error 'no newline at the end of file' although i hit the <return> in the end of file 'after }' three times.
plz help me.
:-|
this is the code:
#include <stdio.h>
main()
{
int m1, m2, m3, m4, m5, per;
printf("Enter marks in five subjects\n");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
per=(m1+m2+m3+m4+m5)/5;
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");
}
this is the output for:
[root@localhost lbin]# gcc -o division division.c
division.c:30:1: warning: no newline at end of file
The executable file division is runing successfully,just i want to know why there is the error 'no newline at the end of file' although i hit the <return> in the end of file 'after }' three times.
plz help me.
:-|
Did you save it or did it automatically save after entering the 3 lines? [And next time, try to put your code between code tags ([code][/code]).]
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Mar 2004
Posts: 1,620
Reputation:
Solved Threads: 51
Hello,
I used the pico editor to cut your text, and paste them into my RedHat 9 box. Then closed the editor, and it compiled just fine.
Maybe you are using vi and left something in there. Or Emacs left something. I dunno. Try cat division.c and see if you see any junk in the file.
I do think, however, it is poor program design on two occasions:
* You are using an integer for the division. per = (M+M+M) / 5 What happens if I enter in decimal numbers?
* You are asking for input on one line. Will the computer accept typo corrections? I would input them one line at a time, so that if I do typo, I can correct it without deleting too much. You also do not check to make sure I enter in 5 values. What happens if I only put in four?
(I have tested these conditions. You should too).
Enjoy!
Christian
I used the pico editor to cut your text, and paste them into my RedHat 9 box. Then closed the editor, and it compiled just fine.
Maybe you are using vi and left something in there. Or Emacs left something. I dunno. Try cat division.c and see if you see any junk in the file.
I do think, however, it is poor program design on two occasions:
* You are using an integer for the division. per = (M+M+M) / 5 What happens if I enter in decimal numbers?
* You are asking for input on one line. Will the computer accept typo corrections? I would input them one line at a time, so that if I do typo, I can correct it without deleting too much. You also do not check to make sure I enter in 5 values. What happens if I only put in four?
(I have tested these conditions. You should too).
Enjoy!
Christian
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- no newline at end of file error (C++)
- file linking problem (C++)
Other Threads in the C Forum
- Previous Thread: Structures in functions.
- Next Thread: Passing an array of structs by reference?
Views: 56672 | Replies: 18
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createprocess() database directory drawing dynamic execv feet fgets file floatingpointvalidation fork framework function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes read recursion recv recvblocked reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi






you need to report that to Dani