Drop your questions and assignments as comments To Learn C Programming Language Click here.
Question 2 write a programme that will count from -50 to +10 and display the result 30/June/2014
Question 2 write a programme that will count from -50 to +10 and display the result 30/June/2014
**********************Solution**************************
/*
This programme count from -50 to +10 and display the result, using for loop statement.
*/
/* include the standard input/output function */
#include <stdio.h>
/* calls the main function */
int main()
{ // Here the programme (main function) begin
/* begin variable declared, it marks the beginning of
the number */
int begin;
/* declaration of the end variable, it marks the end of the number(10) */
int end = 10;
/* By using for loop Start count from begin (-50); due check when begin is less than or
equal to end(10); due increase begin by 1 each time something happen OK */
for (begin = -50; begin <= end; begin++)
/* Open the for loop chunk/block of code */
{
/* Display the value of begin each time */
printf("%d\n", begin);
/* ends/close the for loop chunk/block of code */
}
/* Pause for the user to see the result/display */
system("PAUSE");
/* The main function is not going to return any value */
return 0;
/* ends/closes the main function */
}
*******************OR*********************************
To Learn C Programming Language Click here.
/*
This programme uses while loop to count from -50 to +10 and display the result using while loop statement.
*/
#include "stdio.h"
int main()
{
/* Here we are counting from -51 */
int count = -51;
/* provided the condition inside the parenthesis(count < 10) is true keep doing whatever
you see inside the braces */
while ( count < 10)
{
/* start counting, i.e Each time increase count by 1 */
count = count + 1;
printf("%d\n", count);
}
system("PAUSE");
return 0;
}
*****************************END**************************
To Learn C Programming Language Click here.
Question 1 Write a C programme that will request for student score afterwards the programme will remark the student in respect to the entered scores with any of the following Letter Grades; A, B, C, D, E or F, and Display it to the user?
/*
This is a programme that request for students score afterwards the programme will remark the student with a letter grade (A, B, C, D, E or F) for each of the courses ofered by that student
*/
This is the code/programme
To Learn C Programming Language Click here.
Question 1 Write a C programme that will request for student score afterwards the programme will remark the student in respect to the entered scores with any of the following Letter Grades; A, B, C, D, E or F, and Display it to the user?
/*
This is a programme that request for students score afterwards the programme will remark the student with a letter grade (A, B, C, D, E or F) for each of the courses ofered by that student
*/
This is the code/programme
#include <stdio.h>
int main()
{
/* Let ncrs the variable to hold the number of courses offered by the student and shloud of type integer */
int ncrs;
// Let score be the varaible to hold score for each each course at a time
int score;
/* we use count variable to count number of time we have done a particular thing or to keep track of a particular process */
int count;
/* This tells the student what enter but in a NewLine */
printf("\nEnter the number of courses: ");
/* This retrieve the entered value and keep it in the memory loaction called ncrs */
scanf("%d", &ncrs);
for ( count = 1; count <= ncrs; count++)
{
printf("\nPlease Enter the next score: ");
scanf("%d", &score);
/* for a score to vlaid the score must not be < 0 OR > 100 */
if ( score < 0 || score > 100 )
{
/* If the condition above is not mate then tell the user/student that... */
printf("\nThe score you entered is invalid \
or does not fall within range,");
printf(" Please try again\n\n");
/* And when the above happen just stop the entire(break) and
dont follow any other instruction(stop executing */
break;
}
if( score >= 70 )
{
printf("You got an 'A' in this course!!! \n");
}
else if ( score >= 60 )
{
printf("You got a 'B' in this course!!! \n");
}
else if ( score >= 50 )
{
printf("You got a 'C' in this course!! \n");
}
else if ( score >= 45)
{
printf("You got a 'D' in this course!! \n");
}
else if ( score >= 40 )
{
printf("You got an 'E' in this course! \n");
}
else
{
printf("You got an 'F' in this course \n");
}
}
printf( "\n\n Thanks Goodbye!\n\n");
system("PAUSE");
return 0;
}
int main()
{
/* Let ncrs the variable to hold the number of courses offered by the student and shloud of type integer */
int ncrs;
// Let score be the varaible to hold score for each each course at a time
int score;
/* we use count variable to count number of time we have done a particular thing or to keep track of a particular process */
int count;
/* This tells the student what enter but in a NewLine */
printf("\nEnter the number of courses: ");
/* This retrieve the entered value and keep it in the memory loaction called ncrs */
scanf("%d", &ncrs);
for ( count = 1; count <= ncrs; count++)
{
printf("\nPlease Enter the next score: ");
scanf("%d", &score);
/* for a score to vlaid the score must not be < 0 OR > 100 */
if ( score < 0 || score > 100 )
{
/* If the condition above is not mate then tell the user/student that... */
printf("\nThe score you entered is invalid \
or does not fall within range,");
printf(" Please try again\n\n");
/* And when the above happen just stop the entire(break) and
dont follow any other instruction(stop executing */
break;
}
if( score >= 70 )
{
printf("You got an 'A' in this course!!! \n");
}
else if ( score >= 60 )
{
printf("You got a 'B' in this course!!! \n");
}
else if ( score >= 50 )
{
printf("You got a 'C' in this course!! \n");
}
else if ( score >= 45)
{
printf("You got a 'D' in this course!! \n");
}
else if ( score >= 40 )
{
printf("You got an 'E' in this course! \n");
}
else
{
printf("You got an 'F' in this course \n");
}
}
printf( "\n\n Thanks Goodbye!\n\n");
system("PAUSE");
return 0;
}
SHARE THIS POST WITH YOUR FRIENDS...::
Tweet
Please we need tutorial on this cause
ReplyDeleteI mean that we need tutorial on this course
ReplyDelete