Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
98 views

Assignment Programming in C

This document contains 39 programming problems assigned as homework for a first year B Tech course at KIIT University in Bhubaneswar, India. The problems cover a range of fundamental programming concepts in C including data types, operators, control flow, functions, arrays, strings, pointers, structures and file handling. Students are asked to write programs that convert between number bases, perform arithmetic operations, find minimum/maximum values, sort arrays, check for palindromes and more. They are also provided several short questions testing their understanding of C concepts like loops, memory, compilers and more.

Uploaded by

Anwesh Mohapatra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

Assignment Programming in C

This document contains 39 programming problems assigned as homework for a first year B Tech course at KIIT University in Bhubaneswar, India. The problems cover a range of fundamental programming concepts in C including data types, operators, control flow, functions, arrays, strings, pointers, structures and file handling. Students are asked to write programs that convert between number bases, perform arithmetic operations, find minimum/maximum values, sort arrays, check for palindromes and more. They are also provided several short questions testing their understanding of C concepts like loops, memory, compilers and more.

Uploaded by

Anwesh Mohapatra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

B Tech First Year

KIIT University, Bhubaneswar


Home Assignment of Programming in C
1. Convert the decimal numbers to its equivalent binary and hexadecimal number.
a) (65.82)10 = ( ? )2=( ? )8=( ? )16
b) (26.62)10=( ? )2=( ? )8=( ? )16
2. Find out the 1s complement and 2s complement of the following binary numbers.
a) 10000110
b) 11001000
3. Find the output of the following program segment
int main()
{
int a=10,b=7;
a=a-b;
b=a+7;
printf(\n The value of a and b are %d and %d, a, b);
return 0;
}
4. What will be output of the following c program?
#include<stdio.h>
int main()
{
int x=1,y=2;
y=++x;
x=y++;
y=x--;
printf(\n%d=%d,x,y);
return 0;
}
5. What will be output of the following c program?
#include<stdio.h>
int main()
{
int a = -27, b = -4;
printf ("%d", a>b ? a%b : a/b);
return 0;
}
6. Write the output of the following code?
int main( )
{
int x= 0;
switch(x)
{
case 0: printf("\nKIIT);
case 1: printf("\nKISS'); break;
case 2: printf("\nKIMS");break;
default: printf("\nStudent);

}
}
7. Write the output of the following code?
int main()
{
int c=1;
while(1)
{
if (c>5) break;
printf("\t %d",c);
c++;
}
return 0;
}
8. What would be the output of the following program segment?
int k=3;
while(k<100)
{
printf(\t%d,k);
k=k*7;
}
printf("\t%d",k);
9. Write the output of the following code
int main( )
{
int i;
for(i=1; i<10; i=i+3)
printf(%d ,i);
return 0;
}
10. Write the output of the following code
void main( )
{
int i ;
for (i=89; i>0; i=i/7)
printf ("%d\t", i%7);
return 0;
}
11. Write the output of the following code
void main()
{
int x=0, i=1,j=2;
for(i=0;i<5;i++)
for(j=0;j<i;j++)
{
x+=i+j;
printtf("%d",x);
}
printf("\n%d",x);
}

12.How many times "Welcome" is get printed?


#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("Welcome");
}
return 0;
}
13. Definition, short questions and differentiation.
a) Find the value of the expression: z += x + y * z / 4 % 2 1, where x=5,
y=3, z=4.
b) Write the correct statement to round off x, a float, to an int value using
type casting.
c) Write the code segment to find the smallest among three numbers using conditional
operator (ternary operator).
d) What is a conditional operator in C? Explain with suitable example.
e) What is the advantage of arrays? Explain with suitable example.

f) List the different types of constants used in C. Give two examples in each type.
g) What is the purpose of a header file? Is the use of a header file absolutely
necessary?
h)
i)
j)
k)
l)
m)
n)

Draw the block diagram of computer.


Differentiate while and do-while loop.
Differentiate primary memory and secondary memory.
Differentiate linker and loader.
Differentiate compiler and interpreter.
Differentiate break & continue.
Differentiate if else ladder and switch-case

14. Flow charts


a) Draw a flow chart and write the pseudo code to find the largest among three numbers a, b
and c.
b) Draw a flow chart and write the pseudo code to print all natural numbers between 1 to n.
c) Draw a flow chart and write the pseudo code to find the factorial of a given number.
d) Draw a flow chart and write the pseudo code to find the GCD of two positive integer a
and b.
15. WAP to find the sum of digits of a given number.
16. WAP to find the area of a triangle whose three sides are given.
17. WAP to determine whether a year entered through the keyboard is a leap year or not. Hints:
Year divisible by four and not divisible by 100 or year divisible 400).
18. WAP to find the roots of a quadratic equation ax2+bx+c=0.
19. WAP to convert an integer number to binary
20. WAP to find the sum of n numbers entered through keyboard. n is the user input.
21. WAP to test whether a given number is prime or not.
22. WAP to find the reverse of a given number.
23. WAP to check whether an input integer is palindrome number or not.

24.
25.
26.
27.
28.
29.
30.

31.

32.

33.

WAP to generate the Fibonacci series up to the nth term.(Hints: f0=0,f1=1)


WAP to find the factorial of a given number.
WAP to swap two numbers without using a third variable.
WAP to print the sum of all even and odd numbers starting from 1 to 100 in two different
lines.
WAP to print the factors of a given number n.
WAP to enter ten integers into an array and find the smallest and largest numbers.
WAP to display the grade based on the marks of student. The grade is calculated is as follows:
Marks
Grade
90 to 100
O
80 to 89
E
70 to 79
A
60 to 69
B
50 to 59
C
40 to 49
D
< 40
F
Use else if ladder solve the problem.
WAP to print the following o/p on computer screen for n rows. Ex if n= 4 then
*
* *
* * *
* * * *
WAP to print the following o/p on computer screen for n rows. Ex if n= 4 then
1
2 3
4 5 6
7 8 9 10
WAP to print the following o/p on computer screen for n rows. Ex if n= 4 then
A
A B
A B C
A B C D

34. WAP to print the following o/p on computer screen for n rows. Ex if n= 4 then
1
121
12321
1234321
35. WAP to find the smallest and largest numbers stored in an array of n numbers. N is the user
input.
36. WAP to find location of a given number in an array.
37. WAP to sort the elements in ascending order of an integer array.
38. WAP to find the Armstrong numbers (Example 153 = 13 + 5 3 + 33).
st
39.WAP to compare two integer arrays are same or not. In case of non similar print the 1
mismatched element.

You might also like