Past year exercise for programming, Exercises of C programming

Given the solution on how to answer the test

Typology: Exercises

2021/2022

Uploaded on 04/28/2023

mhmh2023
mhmh2023 🇲🇾

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf2

Partial preview of the text

Download Past year exercise for programming and more Exercises C programming in PDF only on Docsity!

Questlon 1 [9 marks) * Test. 201420158 sem Ol * Identify the following as Integer constant, floatingspolnt constant, character constant, string constant, or Anwalld constant, a) UIN_SKUDAT. sould eowntand b) 0.dend & feating =wern{ conekant c) 1234, e Noalng= point constant Queatlon 2 [4 marks} AC program contains the following declaratlons and Initlal assignments: Int] 10, #9, k, Ga float x= 0.5, y* 0.1; Determine the value for each of the following assignment expresstons. Use the values Initially assigned to the variables for each expression. a) k= 0,09%1 + ao b) c= (xty < 2) 6& (Loe je ad ¢) ye yet 5.0/d2 rob d) z= y/x % pow(2,2)7 a4 Question 3 [4 marks] a) Writea printé statement to generate the message Enter real numbers x and ys Then write a scanf statement to read x and y Inthe same line with the message. Assign the data to floating point varlables x and y. print£C" Enter real numbers x and y? "Ys Scant" Yl At" gx r8y)5 b) Suppose that x1. Is a character variable with an initial value of ‘A’ and x2 Isa floating-point variable with an initial value of 1234. Write asingle printf statement to generate the following screen output; xl eA x2 = 1.234e+003 pant C0 x4 2 %c \n xa s Mode "yD xtyxa ) ¢) AC program contains the following declarations and initial assignments: float x = 3, y= 4; Using only x and yas the variables, writea print £ statement to display the following output, where length of vector is x? +)? : Length of vector is: 5.00 Prenat Length of vector ts i oak ")sqetn tn ¢ yty);