Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

I've got these programs to write but I'm unable to make it work. Could you help me with the codes of these two pragrams. I'm using Dev C++ . If possible use Library.

Computer Science
See more answers at
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

4. According to University regulations, the following mapping between a student’s final mark and the indicative classification of degree is provided for guidance of the board of examiners. >= 70 First Class Honours 60-69 Upper Second Class Honours 50-59 Lower Second Class Honours 40-49 Third Class Honours <40 Not an honours degree (There are other regulations that affect the degree classification.) Write a program to prompt the user to enter a mark as a floating point number. Check that the mark is in the range 0.0 – 100.0 and, if it is, display the indicative degree classification according to the mapping above and if not, then display a message saying that the marks input is invalid. Test your program to ensure that the mapping is correct. 5. The UK sequence of traffic lights is: "Red" (means stop); this is followed by: "Red and Amber" (means prepare to go); this is followed by: "Green" (means go); this is followed by: "Amber" (means prepare to stop); this is followed by: "Red"; etc.. Write a program that prompts the user to enter the current state of a traffic light, then displays the next state. For example, if the current state is "Red and Amber", the next state is "Green". Use a menu system to obtain the current. Thank You..!! :)
//Program For question number 4... #include void main() { float num; cout<<"Enter marks:"<>num; if(num>=0.0 && num<=100.0) { if(num>=70.0) cout<<"First Class Honours"; else if(num>=60.0 && num<70.0) cout<<"Upper Second Class Honours"; else if(num>=50.0 && num<60.0) cout<<"Lower Second Class Honours"; else if(num>=40.0 && num<50.0) cout<<"Third Class Honours"; else if(num<40.0) cout<<"Not an honours degree"; } else { cout<<"Marks input is invalid"; } }
No, no, please, never, no. I would avoid using Dev-C++ in favor of downloading the latest MinGW build of gcc or building clang yourself. Avoid doing what @compute advocated above, because not only should that code not work but it sets forth some very bad practices. Always declare main to be int and use the standard includes i.e. not . Anyways, since you should use standard includes, remember that all the members are in the std namespace... though, actually, very little of that was relevant, since you appear to be a C programmer (hence ). Again, I urge you to just download the MinGW build of gcc or build clang, as both are more-or-less C99-compliant compilers.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

// Program For Question Number 5... #include int main() { int ch; while(1) { cout<<"\n 1.Red\n 2.Red and Amber\n 3.Green\n 4.Amber\n 5.Exit\n"; cout<<"Enter ur choice\n"; cin>>ch; switch(ch) { case 1: cout<<"Red and Amber\n"; break; case 2: cout<<"Green\n"; break; case 3: cout<<"Amber\n"; break; case 4: cout<<"Red\n"; break; case 5: return(0); default:cout<<"Invalid Choice\n"; break; } } }
@oldrin.bataku I m not familiar wid dis version of C++(Dev C++). I had written dat progrm only in C++ language...and I hope it will work in dat version also. and I think the things u had written about d syntax will work in linux os not in windows...
@compute your code is that which is not standards-compliant and therefore not portable. By the way, C++ has a built-in bool type, so no need to use 1 in place of true. Aside from that, the OP asked for C code, not C++, and your solution for 5 doesn't work.
@oldrin.bataku he had mentioned dat he is using some version of c++ so I had written those progm in d way where is problm in 5 becz its working in my systm...
Nevermind, I misread question 5... but my point still stands. Remove from your mind this notion of "versions" of C++; concern yourself with what the standard guarantees, and maybe in some cases compiler-specific implementation-defined behavior or extensions.
..Thank you for your answers..!! @oldrin.bataku ...This is the program the lecturer told us to use. So that's why I'm using that one.
@oldrin.bataku if u have a better solutin den why didn't u post here, it will be helpful 4r me also...
@JadeEyes r these prgms wrkng in ur system????
I'm checking it..!! :)
They work..!! Thank you..!! :) ..!!
#include int main() { double mark; fputs("Mark: ", stdout); scanf("%lf", &mark); if (mark > 100 || mark < 0) { puts("The mark input is invalid"); } else if (mark >= 70) { puts("First Class Honours"); } else if (mark >= 60) { puts("Upper Second Class Honours"); } else if (mark >= 50) { puts("Lower Second Class Honours"); } else if (mark >= 40) { puts("Third Class Honours"); } else { puts("Not an honours degree"); } }
@oldrin.bataku nice program but I think dere is some problm in ur logic becz 1) why u had written marks greater than 100 and less than 0??? 2) In if condition u use a symbol 4r 'or' means any one of d condition will true it will work...means if number is gearter than 100 or number is less than 0...???
The code works fine and is in C using stdio.h like OP requested. The following code also works. #include int main() { double mark; fputs("Mark: ", stdout); scanf("%lf", &mark); puts(mark > 100 || mark < 0 ? "The mark input is invalid" : mark >= 70 ? "First Class Honours" : mark >= 60 ? "Upper Second Class Honours" : mark >= 50 ? "Lower Second Class Honours" : mark >= 40 ? "Third Class Honours" : "Not an honours degree"); }

Not the answer you are looking for?

Search for more explanations.

Ask your own question