For each of the following problems design the flowchart and


For each of the following problems, design the flowchart and the pseudo-code. a) A computer controlling a gate works an follows: ll prompts the user to enter a code using a keyboard. If the code matches the secret code (123), it displays the message \"Welcome, please get in\", if not it displays \"Invalid code, \". b) A machine sorting eggs reads the egg\'s weight then sorts the egg and displays its category according to the following scheme: c) Write a program the computes the following sum: S = 1 + 2 + 3 +......n. Where n is a number entered by the user. The program must ensure that value entered for n is positive.

Solution

C. A program to find the sum of Natural Numbers :-

#include<stdio.h>
int main()
{
int n, i;
int S = 0;
  
printf(\"Enter a positive Integer to compute the sum \") ;
scanf(\"%d\", &n) ;
  
for(i = 1; i <= n; i++)
{
S = S + i;
}
  
printf(\"The Sum of Natural Numbers is = %d\", S) ;
return 0 ;
}

 For each of the following problems, design the flowchart and the pseudo-code. a) A computer controlling a gate works an follows: ll prompts the user to enter a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site