0% found this document useful (0 votes)
56 views7 pages

Lab Manual: Report: Lab 2 "Computer Fundamentals"

This lab manual document describes two programs written in C programming language. The first program asks the user to input a mark and prints the corresponding letter grade based on a grading criteria. The second program allows the user to enter an integer representing the day of the week and prints the name of the day. Screenshots are provided of both programs running successfully and their executable files.

Uploaded by

Safwan Nasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views7 pages

Lab Manual: Report: Lab 2 "Computer Fundamentals"

This lab manual document describes two programs written in C programming language. The first program asks the user to input a mark and prints the corresponding letter grade based on a grading criteria. The second program allows the user to enter an integer representing the day of the week and prints the name of the day. Screenshots are provided of both programs running successfully and their executable files.

Uploaded by

Safwan Nasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Lab Manual

Computer Fundamentals and Programming

Report: Lab 2 “Computer Fundamentals”


Lab Task -01
Write a program that ask users to input marks of a subject and print the letter grade (See grading
criteria below). For details see the following sample execution of the program

Grading Criteria
Marks 51 – 60 D
Marks 61 – 70 C
Marks 71 – 80 B
Marks 81 – 100 A

Sample Output-1
Enter the marks: 80
Grade: A
CODE:
#include <stdio.h>
int main()
{
float marks;
printf ("Enter the marks: ");
scanf ("%f",&marks);
if (marks>=81&&marks<=100)
printf("Grade:A");

else if(marks>=71&&marks<=80)
printf("Grade:B");

else if (marks>=61&&marks<=70)
printf("Grade:C");

else if (marks>=51&&marks<=60)
printf("Grade:D");

else
printf("Invalid input");

getchar();getchar();
return 0;
}

Here is shown the screenshot of the above program and its executable file.

Figure 1Screenshot of above program

1|Page
Here is shown the executable file of the above program.

Figure 2.exe file

2|Page
Lab Task -02
Write a program that allow user to enter the day of the week as integer value e.g. for Monday the
user can enter 1, for Sunday user can enter 7.

The program should print the name of the day by using this integer value

Code:
#include <stdio.h>

int main()

int day;

printf ("Enter the day of the week as integer value e.g., 1 for Monday:
");

scanf ("%d",&day);

switch (day)

case (1):

printf ("Monday");

break;

case (2):

printf ("Tuesday");

break;

case (3):

printf ("Wednesday");

break;

case (4):

printf ("Thursday");

break;

3|Page
case (5):

printf ("Friday");

break;

case (6):

printf ("Satday");

break;

case (7):

printf ("Sunday");

break;

default:

printf ("Invalid Input");

getchar();getchar();

return 0;

4|Page
Here is shown the screenshot of the above program and its executable file.

Figure 3Screenshot of above program

5|Page
Here is shown the executable file of the above program.

Figure 4.exe file

6|Page

You might also like