Professional Documents
Culture Documents
#include<stdio.h>
void main (void)
{
float f, c ;
printf(“Please Enter Temperature in Fahrenheit => ”) ;
scanf(“%f”, &f) ;
c = (5 / 9) * (f – 32) ;
printf(“\nTemperature in Celsius = %f”, c) ;
}
OR
#include<stdio.h>
void main (void)
{
float f;
printf(“Please Enter Temperature in Fahrenheit => ”) ;
scanf(“%f”, &f) ;
printf(“\nTemperature in Celsius = %f”, (5 / 9) * (f – 32) ) ;
}
#include<stdio.h>
void main (void)
{
float f, c ;
printf(“Please Enter Temperature in Celsius => ”) ;
scanf(“%f”, &c) ;
f = c * (9 / 5) * + 32 ;
printf(“\nTemperature in Fahrenheit = %f”, f) ;
}
OR
1
#include<stdio.h>
void main (void)
{
float f;
printf(“Please Enter Temperature in Celsius => ”) ;
scanf(“%f”, &c) ;
printf(“\nTemperature in Fahrenheit = %f”, c * (9 / 5) * + 32) ;
}
#include<stdio.h>
void main (void)
{
unsigned int a, b, c;
printf(“Please Enter Value of Integer Number a => ”) ;
scanf(“%d”, &a) ;
printf(“Please Enter Value of Integer Number b => ”) ;
scanf(“%d”, &b) ;
printf(“Please Enter Value of Integer Number c => ”) ;
scanf(“%d”, &c) ;
if (a >= b)
{
if (a >= c)
printf (“Maximum Value = %d”, a);
else
printf (“Maximum Value = %d”, c);
if (b >= c)
printf (“Minimum Value = %d”, c);
else
printf (“Minimum Value = %d”, b);
}
else
{
if (b >= c)
printf (“Maximum Value = %d”, b);
else
printf (“Maximum Value = %d”, c);
if (c >= a)
printf (“Minimum Value = %d”, a);
2
else
printf (“Minimum Value = %d”, c);
}
}
#include<stdio.h>
void main (void)
{
unsigned int num = 1 ;
outer_loop:
if (num == 9)
goto stop_printing ;
inner_loop:
printf (“%d\t”, num) ;
num++ ;
if (num % 3 != 0)
goto inner_loop ;
else
goto outer_loop ;
stop_printing ;
}
3
Q : 15-01-05 : Write a program in C Language to Calculate and Print The
Area of a Geometrical Figure (Square, Rectangle, Right-Angle Triangle, Circle with
appropriate formula). (Take Values from user.). One of following required in EXAM (not all
simultaneously).
// Area of Square
#include<stdio.h>
void main (void)
{
float s, area ;
printf(“Please Enter Length of Side of Square => ”) ;
scanf(“%f”, &s) ;
area = s * s ;
printf(“\nArea of Square = %f”, area) ;
}
// Area of Rectangle
#include<stdio.h>
void main (void)
{
float length, width, area ;
printf(“Please Enter Length of Rectangle => ”) ;
scanf(“%f”, &length) ;
printf(“Please Enter Width of Rectangle => ”) ;
scanf(“%f”, &width) ;
area = length * width ;
printf(“\nArea of Rectangle = %f”, area) ;
}
// Area of Right-Angle Triangle
#include<stdio.h>
void main (void)
{
float base, perpendicular, area ;
printf(“Please Enter Base of Triangle => ”) ;
scanf(“%f”, &base) ;
printf(“Please Enter Perpendicular of Triangle => ”) ;
scanf(“%f”, &perpendicular) ;
area = base * perpendicular / 2 ;
printf(“\nArea of Right-Angle Triangle = %f”, area) ;
}
4
// Area of Circle
#include<stdio.h>
void main (void)
{
float radius, area ;
printf(“Please Enter Radius of Circle => ”) ;
scanf(“%f”, &radius) ;
area = (22 / 7) * radius * radius ;
printf(“\nArea of Circle = %f”, area) ;
}
#include<stdio.h>
void Print_Asterisks (void) ; // function prototype
void main(void)
{
// Function call
Print_Asterisks ( ) ;
}
5
Q : 15-01-07 : Write a program in C Language to Print Following Output
with the Help of Nested Loop statement.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
#include<stdio.h>
void main (void)
{
unsigned int num ;
printf(“Please Enter a Number => ”) ;
scanf(“%f”, &num) ;
for (int i = 1 ; i <= num ; i ++)
{
for (int j = 1 ; j <= num ; j ++)
{
printf(“%d\t”, i) ;
}
}
} // Enter Value 9 and see result