Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
36 views
9 pages
6 Introduction To C Programming
Uploaded by
Nanda Thakare
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save 6 Introduction to C Programming For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
36 views
9 pages
6 Introduction To C Programming
Uploaded by
Nanda Thakare
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save 6 Introduction to C Programming For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save 6 Introduction to C Programming For Later
You are on page 1
/ 9
Search
Fullscreen
“EXERCISES” Q.1. Fill in the blanks : (1) C is a High level language. (2) A€ program must be compile before it can be executed. (3) Anamed area in memory that stores a character or numeric value is © called Variable. (4) In C, a number containing a decimal point of type float. 2 (5) The memory size of a floating 2 point number is usually 4 bytes. (6) The equality checking operator in > Cis. 2 (7) *%C” is the standard function to read a single character from keyboard. 2 Q.2. State whether the following statements are true or false. (1) Cis a interpreted language. Ans : False (2) In C, an user must define the 2 meaning of keyword used.(3) The type of variable determines what kind of values it may take on. Ans : True (4) A variable name can be begin with underscore, Ans : False (5) A variable declaration tells the name and type ofa variable. Ans : False (6) “34.5” is a numeric constant, Ans; False (7) The keyword int is used to declare © a constant. Ans : False (8) The expression 4+5*6 will evaluate to 54. Ans : False (9) The expression 4 * 2 to find the square of 4 is valid in C, Ans : False (10) The standard C functions are grouped into header files. Ans : True (11) The standard C function tofind the absolute value of anumber x ¢ is abs(x). Ans : False (12) The format specifier for an integer in a printf statement in Cis \n, & Ans : False (13) Explanatory comments in C are given with the REM keyword. Ans : False Q.3. Give the purpose of each of the following in a C program, (1) float: float is a data type to store a © floating point number. E. 14 (2) char : char is a data type to store \4 a character. E.g. : ‘a” 2 (3) getchar() ; The function input a simple character from the keyboard. (4) scanf : The function performs formatted input. E.g. scanf(“%d”, & a); 3 (5) stdio.h : stdio.h is a header file which predefined standard input and $ output function. 2 (6) math.h : math.h is a header file which predefined mathematical function(7) \t = It is am escape sequence which is used in print. Q.4, Answer the following questions in e one or two sentences each : (1) What are the primary data types in$ G2. Ans : int (integer), char (Character), float (floating point number) and c double are the primary data type in C. © (2) What is a numeric constant? Ans : Numeric constant is a number. E.g. 2,3.142. > (3) What does the modulus operator do inc. Ans : Modulus operator returns the mode of a division. E.g. 4 % 3 = 1. 2 (4) What is the deference between the operators = and ==? is a assignment operator eg. s evaluating 2 numbers to find out the big one. (5) What is a header file? Ans : Header file is a predefined function which can be used in our program.(6) State the parts of a C program? Ans : Heading, inclusion, function main() with statements and optional user defined functions. (7) What is the purpose of the inclusion statements in a C program?? ¢ Ans : To include predefined user function to user program. Q.5. Write the C expression for. (1) raising 2 to the power 5: pow(2,5)s © (2) a= 7b +1 : pow(a,3)- (7*b)+1 (3) (5(f-32))/9 : (5 * (-32)/9 Q.6. Identify the valid variable name’ in C: m, N, 7N,-avg, Yod. 3 Ans: m,N. Q.7. The following statement block in C is supposed to calculate (at+b)’, but there are errors. Find out the errors and rewrite the statement block. int a ==5, b=6,ans ans=(at+b)*3; printf(The answer is, ans); 2 Ans : int a=5,b=6,ans; ans=(a+b) * 3; > printf(“The answer is %d “, ans); ==>Q.8. Answer the following in brief : (1) State the limitations of naming the variable in C. Ans : (i) Every variable name must start with a letter 0 an underscore. (ii) C recognizes upper and lowercase characters as being different. (iii) You cannot use nay of C's keywords (the words such as main, while, switch, ete. which are part of the syntax of the language) as variable © names, (2) Write short note on relational operators. Ans : These operators are used to make comparison and control the > flow of logic in a program using the if 2 and switch statements. 2 (3) Write short note on program > structure in C. Ans ; The program starts with a series 3 of comments indicating its purpose, as well as its author. This is called 3 heading, It is considered good programming style to identify and 3 document your work. Explanatory 3 comments can be written anywhere in the code ; all characters between /* 2 and */ are ignored by the compiler and 2 can be used to make the code easier to understand,Q.9. Write C programs for the following : (1) Input a value for the radius of a circle and display the area of the circle. Ans: #include
main() { float areayr; float PI=3.14; printf("enter radius\n"); seanf("%f",&r); area=PI*r*rz printf("area of circle is %f",area); 2 (2) Input the value for the side of a 2 square and display its perimeter and 5 #include
2 #include
2 int main(){ float side, area; printf(""Enter length of side of 2 square\n"); scanf("%f", &side); /* Area of Square = Side X Side */ area = pow(side, 2); printf("Area of square : %0.4f\n", > area);perimeter = 4*side: printf("Perimeter of Square : %0.4f\n", perimeter); getch(); return 0; (3) Input two numbers and display the square of their sum. Ans: #include
#include
int main() { int num1, num2, sqrl, sqr2, sum; printf("Enter any two numbe ds seanf("%d%d", &num1, &num2); sqrl = num1*num1; sqr2 = num2*num2; sum = sqrl + sqr2; printf("Sum of their square = %d", sum); getch(); return 0; } Q.10. Write C programs for the following problems from your mathematics textbook : (1) The radius of the base of a cone is § cm and its slant height is 13 cm. Find. the volume of the cone.Ans: #include
int main() { const float PI = 3.14; float r, h, volume; r=5; h=13; volume =(PI* r*r* h)/3.0; printf("Volume of Cone is %f\n", volume)3} (2) The base area of a cone is 10.5. square units and its slant height is 10 cm, What is the curved surface area of $ the cone? Ans: #include
#include
#define PI 3.14159 int main(){ float radius, height, surfaceArea; radius = 10.5; height = 10; surfaceArea = PI*radius*(radius + sqrt(height*height + radius*radius)); printf("Total surface area of Cone ; %0.4f\n", surfaceArea); return 0; —————————
You might also like
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (643)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (298)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1175)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4.5/5 (1856)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2289)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (144)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (244)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (629)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4.5/5 (1139)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (836)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2885)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2546)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (233)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (903)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M.L. Stedman
4.5/5 (815)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (919)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4.5/5 (4103)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1267)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)