[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Pseudo-code

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 9
Thread images: 1

File: 1473699927332-2008835500.jpg (4MB, 4128x2322px) Image search: [Google]
1473699927332-2008835500.jpg
4MB, 4128x2322px
Hey guys, I've been having trouble with this assignment question and I was wondering if you could help me with it . The highlighted text is the question that's been bugging me. Your help will be very much appreciated

>Create a Pseudo-code that will accept the percentage marks for 5 students and display the number of students who passed and number of students who failed, if the percentage mark is greater than or equals to 50 then increment the number of passes by 1 and any percentage mark less than 50 increments the number of fails by 1.
>>
>>188971
Bump
>>
Here this code shall work fine:-

float arr[4];
int pass=0;
int fails=0;
for(int i=0;i<5;i++)
{
cout<<"Enter marks of student";
cin>>arr[i];
if(arr[i]>=50)
{pass++;}
else
{fails++;}
}
cout<<"Number of passed students are: "<<pass;
cout<<"\n Number of failed students are: "<<fails;
>>
>>188988
Holy crap , the wait was worth it . Thanks anon . Keep doing gods work!
>>
>>188988
The question said to do it in pseudo code.
>>
>>188993
Plus you're using an array for data you write once, read once, then discard.
Plus you have a buffer overrun: you're declaring arr[4], then writing to arr[4], which is actually int pass;
Plus you're using a float to store a rational, where you should be using an int.

Even if you were meant to write C (which you're not), your code is dreadful, and instead of coming up with the right answer, will say the pass total is whatever mark the fifth guy got.

When there was no reason to be storing marks in the first place.
>>
>>189118
yea i know i stored marks for absolutely no way but generally in such "report card" cases they start teaching by creating arrays to store data... his is a process of learning. I think data type to be used is float and not int as marks can be 60.5% which if stored in integer data type would cause data loss and also my code is written for C++ and not C. also a code written in c++ (the most basic programming language) is almost as simple as a psuedo code and this would help OP learn more. :) Please don't spread hate if you may
>>
>>188993
Always happy to help :)
>>
>>189118
>Plus you're using a float to store a rational, where you should be using an int.
>Even if you were meant to write C

Never post again.
Thread posts: 9
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.