0% found this document useful (0 votes)
38 views2 pages

CS114 - Assignment1

The document outlines the first assignment for CS114 Fundamentals of Programming, due on December 17, 2021. It includes tasks such as arranging code for integer addition, correcting erroneous statements, and writing programs for various calculations involving integers and circles. Students are required to submit their work via email with proper documentation and formatting.

Uploaded by

Awais jatoi
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)
38 views2 pages

CS114 - Assignment1

The document outlines the first assignment for CS114 Fundamentals of Programming, due on December 17, 2021. It includes tasks such as arranging code for integer addition, correcting erroneous statements, and writing programs for various calculations involving integers and circles. Students are required to submit their work via email with proper documentation and formatting.

Uploaded by

Awais jatoi
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/ 2

CS114 Fundamentals of Programming

Assignment 1
Deadline: 17th December 2021, 11:59 PM
Submission: Email your assignment as a single word file to Miss Ain Zia at
[email protected]. You must include your name, registration
number and section at the top of your assignment. Coding should be neat,
readable, and have the necessary commenting and documentation.

Question 1:

Arrange the following lines of code to display the addition of two integers:

printf ( “ Enter second integer : ”);


int main ( void)
printf (“Sum is %d \n”, sum) ;
{
printf ( “ Enter first integer : ”);
#include < stdio.h >
sacnf ( “%d”, &integer1 );
return 0;
sacnf ( “%d”, &integer2 );
sum = integer1 + integer2;
}
int integer1, integer2, sum;

Question 2:

For each of the following statements, explain why it is not correct, and fix it

a) #Include < stdio.h >;


b) #define PI = 3.14159
c) printf ( "The product of %d and %d is %d"\n, x, y );
d) int 9value;
e) float enum=5.89;

Question 3:

Write a single C statement to accomplish each of the following:

a) Prompt the user to enter an integer. End your prompting message with a colon (:) followed
by a space and leave the cursor positioned after the space.
b) Read an integer from the keyboard and store the value entered in integer variable a.
c) Print the message "This is a C program." on one line.
d) Print the message "This is a C program." on two lines so that the first line ends with C.
e) Print the message "This is a C program." with each word on a separate line.
Question 4:

Write a program that calculates the product of three integers. Use scanf to read the values of
integers. Add comments in your program. (To get full marks your code should be legible, not only
just correct)

Question 5:

Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference
and area. Use the constant value 3.14159 for π. Perform each of these calculations inside the printf
statement(s). Add comments in your program. (To get full marks your code should be legible, not
only just correct)

You might also like