Escolar Documentos
Profissional Documentos
Cultura Documentos
explanations.
Question 1:
(a) Write a simple program to find the size of different basic data types in C.
Ans:- #include<stdio.h>
#include<conio.h>
void main()
clrscr();
getch();
Your program should guide users with proper message/menu on the console.
# include<stdio.h>
void main()
{
menu();
}
menu()
{
int i, a =0,b=1,c;
printf(“Enter the operation need to be performed” \n);
printf(“Enter 1 to perform And operation” \n);
printf(“Enter 2 to perform OR operation” \n” \n);
printf(“Enter 3 to perform NOT operation” \n);
printf(“Enter 4 to exit” \n);
scanf(“%d”, i);
if (i==1)
c=and(a,b);
else if(i==2)
c=OR(a,b);
else if(i==3)
c=not(a,b);
else if(i==4)
exit(0);
printf (“The result is %d”, c);
menu();
}
and(a,b)
{
return (a&&b);
}
or()
{
return (a||b);
}
not(a)
{
return (!a);
}
}
(c) Write a function to find the area of a triangle whose length of three sides is
given
#include<stdio.h>
02 #include<math.h>
03 int main()
04 {
05 float a,b,c,s,area;
07 scanf("%f%f%f",&a,&b,&c);
08 s=(a+b+c)/2;
09 area=sqrt(s*(s-a)*(s-b)*(s-c));
11 return 0;
12 }
Question 2:
***
*****
*******
*********
************
(b) Write a C program to read the internal test marks of 25 students in a class
and
show the number of students who have scored more than 50% in the test.
Question 3:
(a) What is calling by reference? How it is different from call by value?
Write a C function to swap two given numbers using call by
reference mechanism.
Question 4:
(b) What is a pointer? Explain pointer arithmetic with example. Also explain use of
malloc function in C programming with an example
Question 5:
(a) Explain recursion. Also write a C program for Tower of Hanoi problem with
a example of 4 disks .