Skip to content

Ahmet Faruk Bişkinler

CENG101Quiz1 PDF Yazdır e-Posta
(0 votes, average 0 out of 5)
Lessons - CENG 101 Computer Programming I
Administrator tarafından yazıldı.   
Cumartesi, 17 Haziran 2006 11:37
Etiketler:

Quiz # 1 With Their Solutions (8/3/2005)

Q1) Write a single C statement to do the following:
Read an integer value from the keyboard and store the value entered in integer variable called num.
b. Declare the variables x, y, z and result to be of type float.
c. Print the message ?Our first quiz? on one line. 

Q2) Write a program that asks the user to enter the 3 numbers.Find the sum and the average of the 3 numbers. Then print the results.

Quiz #1 Solution
CENG 112 /A
8/3/2005


Q1) Write a single C statement to do the following:
Read an integer value from the keyboard and store the value entered in integer variable called num.
scanf("%d", &num);

b. Declare the variables x, y, z and result to be of type float.
float x, y, z, result;

c. Print the message ?Our first quiz? on one line.
printf("Our first quiz");



Q2) Write a program that asks the user to enter the 3 numbers.Find the sum and the average of the 3 numbers. Then print the results.


#include
int main()
{
float num1, num2, num3, sum; //float declaration
float average; //float declaration
printf("Please enter 3 numbers");
scanf("%f%f%f", &num1, &num2, &num3); //reading 3 numbers from user
sum = num1+num2+num3; //finding sum
average = sum/3; //finding average
printf("Sum is:%f\nAverage is %f", sum, average); //printing results


return 0;
}

 

Etiketler:
Son Güncelleme: Cumartesi, 13 Ocak 2007 23:37
 

Yorum ekle


Güvenlik kodu
Yenile