Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Question Number# 2
Write a program to illustrate whether standard library function
truncates or round when printing out a floating point Numbers.
Program
#include <stdio.h>
#include <conio.h>
int main ()
{
int r;
printf("enter your number\n");
scanf("%d",&r);
printf("The round value is\n");
printf("%d",r);
getch();
Question Number# 3
Write o program to check what the fillowing code segment
output and explain the results.
Char c;
printf("sizeof(c) = %d\n",sizeof(c));
printf("sizeof(a) = %d\n",sizeof('a'));
printf("sizeof(c='a') = %d\n",sizeof(c='a'));
Program
#include <stdio.h>
#include <conio.h>
int main ()
{
char c;
printf("sizeof(c) = %d\n",sizeof(c));
printf("sizeof(a) = %d\n",sizeof('a'));
printf("sizeof(c='a') = %d\n",sizeof(c='a'));
getch();
}
Result
printf("sizeof(c) = %d\n",sizeof(c));
printf("sizeof(a) = %d\n",sizeof('a'));
printf("sizeof(c='a') = %d\n",sizeof(c='a'));
Question Number# 4
Run the “Hello Word” program on your system. Experiment with
leaving out part of the program, to see what error message to
get?
Program
#include <stdio.h>
#include <conio.h>
int main ()
{
char c;
printf("Hello world");
}
Error
If (;)is missing then syntax error before ‘getch’ occure.
Question Number# 5
Question Number# 6
getch();
}
Question Number# 7
In an integer from the keyboard and print out its character
representation Make certain you carry out appropriate bound/error
checking.
Program
#include <stdio.h>
#include <conio.h>
int main ()
{
char a;
scanf("%c",&a);
if(a==a)
printf("65");
if(a==b)
printf("66");
getch();
}
Question Number# 8
Write a program to read Fahrenheit tempture and print them in
Celsius. The formula is C=(5/9)(F-32) use variable of type double
in your program.
Program
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main()
{
double f,c;
c = (5/9)(f-32);
Question Number# 9
Write a program that reads in the radius of a circle and prints the
circle’s diameters, cumference and area. Use the value 3.14159
for”pi”
Program
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float a;
float r;
float c;
float d;
float pi=3.141593;
printf("ENTER RADIUS= ");
scanf("%f", &r);
a=2*pi*r*r;
c=2*pi*r;
d=2*r;
printf("\n\tArea: %f",a);
printf("\n\tCircumference: %f ",c);
printf("\n\tDiameter:%f",d);
getch()
}