0% found this document useful (0 votes)
22 views4 pages

Practice 1

Uploaded by

Tanim Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Practice 1

Uploaded by

Tanim Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 1

Answer the following questions.

Topics : Number Systems, Data types and Variables, Naming conventions,


Control statements, Loops
[Each question carries 5 marks]

1. Who invented C? Is C a case sensitive language?


2. Do the conversion:
(935.84)10 into binary, octal and hexadecimal
3. Do the conversion:
(1101101.11011)2 into decimal, octal and hexadecimal
4. Do the conversion:
(9CE. A4)16 into decimal, binary and octal
5. If A= 1100001 and B= 1001111
(a) Find A+B
(b) Find A-B and B-A using 2’s Complement method.
6. What are the naming conventions for variables and functions? Which of the
following names can not be used as a variable name? Show your reason.
total$, total_cost, case, 2total, arr15
7. What are preprocessor and preprocessor directives? Show an example.
What is the use of #define and #include?
8. Identify the type of error and show your reason:

a. #include<stdio.h>
int main()
{
int a;
a+=1;
return 0;
}
b. #include<stdio.h>
int main()
{
int a=1;
int b=a/0; return 0; }
9. What will be the value of x here? Give your reasoning.
int x = 10+20*10-(5*3)
10. Write a C program to calculate the following equation for any value of x.

11. Write a C program using switch-case that will read the month number and
display the month name.
12. Write a C program that will change the values of x, y, z in cyclic order.
X -> Y -> Z ->X
13. Rewrite the following code using the if else statement.
#include<stdio.h>
int main()
{
int i;
scanf("%d",&i);
switch(i){
case 1:
printf("one");
break;
case 2:
printf("two");
break;
case 3:
printf("three");
break;
default:
printf("Unrecognized Number");
}
return 0;
}
14. What is the difference between do…while and while loop? What will be the
output of the following code?
int i=0;
do{
printf("%d",i);
i- - ;
}while(i>0);

15. What is the use of break and continue keywords in C? What will be the output
of the following code?
#include<stdio.h>
int main()
{
int i;
for(i=1; i<20; i++)
{
printf(“%d”, i);
if(i==10) break;
}

return 0;
}

16. Write a C program to print alphabets from a to z using ASCII values.


17. Write down a program that will print the second largest of three integers given
as input.
18. What is the purpose of following statement :
for(; ; )
{

}
19. Write code for the following pattern:

20. Write a C program to count the number of digits in a number.

You might also like