0% found this document useful (0 votes)
42 views3 pages

C Programming Exercise-01

The document contains the exercises for a C programming course. It includes 10 exercises on basic C programming concepts like printing output, defining macros, and identifying program output. The exercises cover using printf statements, comments, and basic syntax. The exercises are meant to familiarize students with writing and running simple C programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
42 views3 pages

C Programming Exercise-01

The document contains the exercises for a C programming course. It includes 10 exercises on basic C programming concepts like printing output, defining macros, and identifying program output. The exercises cover using printf statements, comments, and basic syntax. The exercises are meant to familiarize students with writing and running simple C programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

CSE1001 PROGRAMMING I

2022 – 2023 FALL


C PROGRAMMING EXERCISE - 01

Topic : C Fundemantals

Exercise-1 : Displaying Check Mark (checkMark.c)

Definition : The program uses one printf function to display the following picture on the screen.

Expected output:

*
*
*
* *
* *
*

Exercise-2 : Modify the dweight.c program: define INCHES_PER_POUND as a macro for 166.
/* Name: dweight.c */
/* Purpose: Computes the dimensional weight of a 12" x 10" x 8" box */
#include <stdio.h> //directive
int main(void) //main function
{ // starting point
int height, length, width, volume, weight; // variable declaration

height = 8; //assignment: assigns a value to variable height


length = 12; //assignment: assigns a value to variable length
width = 10; //assignment: assigns a value to variable width

volume = height * length * width; //assignment: assigns the result of


multiplication to variable volume.
weight = (volume + 165) / 166; //assignment: assigns the result of
expression to variable weight.

printf("Dimensions: %d x %d x %d\n", length, width, height); //function calling


statement
printf("Volume (cubic inches): %d\n", volume); //function calling statement
printf("Dimensional weight (pounds): %d\n", weight); //function calling
statement

return 0; //return statement


}//ending point

Reference:K. N. King “C Programming: A Modern Approach”, Norton Publishing, 2nd Edition, 2008. 1 /3
Exercise-3 : What is the output of the program?
/* Name: dweight.c */
/* Purpose: Computes the dimensional weight of a 12" x 10" x 8" box */
#include <stdio.h> //directive
int main(void) //main function
{ // starting point
int height, length, width, volume, weight; // variable declaration

height = 8; /* assignment: assigns a value to variable height


length = 12; /* assignment: assigns a value to variable length */
width = 10; /* assignment: assigns a value to variable width */

volume = height * length * width; // assignment: assigns the result of


multiplication to variable volume.
weight = (volume + 165) / 166; // assignment: assigns the result of
expression to variable weight.

printf("Dimensions: %d x %d x %d\n", length, width, height); //function calling


statement
printf("Volume (cubic inches): %d\n", volume); //function calling statement
printf("Dimensional weight (pounds): %d\n", weight); //function calling
statement

return 0; //return statement


}//ending point

Exercise-4 : What is the output of the program?


#include <stdio.h>
int main(void)
{
printf("Brevity is the soul of wit.\n --Shakespeare\n");
return 0;
}

Exercise-5 : What is the output of the program?


#include <stdio.h>
int main(void)
{
printf("Brevity is the soul of wit.\n");
printf(" --Shakespeare\n");
return 0;
}

Exercise-6 : What is the output of the program?


#include <stdio.h>
int main(void)
{
printf("Brevity is the soul of wit.\n\n --Shakespeare\n");
return 0;
}

Reference:K. N. King “C Programming: A Modern Approach”, Norton Publishing, 2nd Edition, 2008. 2 /3
Exercise-7 : What is the output of the program?
#include <stdio.h>
int main(void)
{
printf("Brevity is the soul of wit.\n");
printf("\n");
printf(" --Shakespeare\n");
return 0;
}

Exercise-8 : What is the output of the program?


#include <stdio.h> /* directives */
int main(void) /* main function */
{ /* starting point of the main function */
printf("Brevity is the soul of wit.\n"); /* function calling statement
printf("\n"); /* function calling statement */
printf(" --Shakespeare\n"); /* function calling statement */
return 0; /* return statement */
} /* starting point of the main function */

Exercise-9 : What is the output of the program?


#include <stdio.h> /* directives */
int main(void) /* main function */
{ /* starting point of the main function
printf("Brevity is the soul of wit.\n"); /*function calling statement */
printf("\n"); /* function calling statement */
printf(" --Shakespeare\n"); /* function calling statement */
return 0; /* return statement */
} /* starting point of the main function */

Exercise-10 : What is the output of the program?


#include <stdio.h> /* directives */
int main(void) /* main function */
{ /* starting point of the main function */
printf("Brevity is the soul of wit.\n"); /*function calling statement */
printf("\n"); /* function calling statement
printf(" --Shakespeare\n"); /* function calling statement */
return 0; /* return statement */
} /* starting point of the main function */

Reference:K. N. King “C Programming: A Modern Approach”, Norton Publishing, 2nd Edition, 2008. 3 /3

You might also like