Programming 1
Programming 1
ANS:
ANS:
ANS :
Q 4 : Read an integer from the user at the keyboard and store the value
entered in integer variable age
Omar Sarwt
ANS :
ANS :
ANS :
Q 7 : print the message “this is a c++ program” on two line . End the
first line with c++
ANS :
Omar Sarwt
Q 8 : print the message “this is a c++ program” with each word on a
separate line
ANS :
ANS :
ANS :
Omar Sarwt
Q 12 : Write a program in C++ to convert temperature in Celsius to
Fahrenheit
ANS :
ANS :
ANS :
Omar Sarwt
Q 15 : Write a program in C++ to calculate Area and volume of circle.
ANS :
ANS :
ANS :
Omar Sarwt
Q 18 : Write a C++ code that prompts the user to input two integer
values and find the greatest value.
ANS :
Ans :
Omar Sarwt
Q 20 : Write a C++ program to check whether a number is even or odd
using if else
ANS :
ANS :
(OR)
Omar Sarwt
(OR)
ANS :
Omar Sarwt
Q 23 : Write four different c++ statements that each add 1 to integer
variable x
ANS :
x=x+1;
x +=1 ;
x ++ ;
++x ;
ANS :
z = x++ + y ;
ANS :
ANS :
Omar Sarwt
Q 27 : calculate the remainder after q is divided by divisor and assign
the result to q .Write this statement two different ways
ANS :
(OR)
b-set variable x to 1
d- add variable x to variable sum and assign the result to variable sum
ANS :
Omar Sarwt
ANS :
Q 30 : state the values of each variabl after the calculation is performed
assume that , when each statement begins executing , all variables have
the integer value 5
X++
;a- product *= x++
يعني الزياده مبتحصلش فوقتها بمعني ان
;b-quotient /=++x االكس بتفضل بقيمتها القديمه وهنا
فالسؤال عندنا معلومه مهمه هي ان اي
ANS OF a : متغير قصده علي البرودكت واالكس
والكوتنينت كل منهم بيساوي 5وبكدا
Product = product * x++ = 5*5=25 تكون قيمه االكس بكام ؟ هتبقي بتساوي
5عشان زي ماقولنا مبتحصلش الزياده
X=5
فساعتها
ANS OF b :
Omar Sarwt
Q 31 : write a c++ program to print integer number from 1 to 10 , when
counter become greater than 10 end program . using for , while and
do..while statement.
ANS :
ملحوووووووووووظه
Omar Sarwt
وظيفته الوحيده انه هيعمل مسافه بين كل رقم ورقم عشان زي ماحنا عارفين ان اي حاجه جوا
عالمه التنصيص دول بتطبع زي ماهي فاحنا سبنا مسافه جوا عالمه التنصيص عشان تطبع
مسافه فبدون عالمه التنصيص مش هيطبع مسافه كدا وهتظهر االوت بوت كدا
Q 32 :
2 , 5 , 8 , 11 , 14 , 17 , 20
99 , 88 , 77 , 66 , 55 , 44 , 33 , 22 , 11 , 0
Omar Sarwt
Q 33 : write a c++ program to sum the even integers from 2 to 20
ANS :
ANS :
(OR)
Omar Sarwt
Q 35 : write a program to print integers from 1 to 10 except 5
ANS :
ANS :
Omar Sarwt
Q 37 : write a program to compute average of marks of 3 subjects for
“n” students
ANS :
ANS :
Omar Sarwt
Q 39 : sum the odd integers between 1 and 99 using for statement.
ASSUME the integer variable sum and count have been declared
ANS :
ANS :
Omar Sarwt
ANS :
ANS :
ANS :
Omar Sarwt
Q 44 : Write a program to read an integer number from the user, and
then print the absolute.
ANS :
ANS :
(and)
Omar Sarwt
Q 46 : Write a C++ program of simple calculation that will get two
numbers and support all those operations (+, - , *, /).
ANS :
Q 47 : Write a program that reads a triangle sides (L1, L2, L3) and prints
these sides are :
ANS :
Omar Sarwt
Q 48 : Write program to print all numbers dividable by 10 from 0 to 100
ANS :
(OR)
Q 49 : Write C++ program read numbers from user and each time user
enter number program can decided if this number divided by 5 or 3
and user enter -1 for stop.
ANS :
Omar Sarwt
Q 50 : Write program to print multiplication table from 1 to 4 .
ANS :
Omar Sarwt
Q 51 : write program to print multiplication from user input and if input
is greater than 4 or less than 0 print “out of range” and end program.
ANS :
ANS :
Omar Sarwt
Q 53 : Write a program to display the numbers from 1 to 10, their
squares, and their cubes as a table by using while.
ANS :
ANS :
ANS :
Omar Sarwt
Q 56 : writeone or more statements that perform the folllowing tasks
for and array called fractions :
Omar Sarwt
Q 57 : Answer the following questions regarding an array called table:
been defined to be 3.
Omar Sarwt
ANS :
Omar Sarwt