(S.P) assignment -1 [ C Batch ]
Please, view the site in windows mode
Question:- 1 Write a C program that we print your mailing address in the following form.
Name
Street and Door No.
City, Pincode
#include <stdio.h>
#include <conio.h>
void main ()
{
clrscr();
printf("XYZ \nA-201, Shree Apt., \nNr. Petrol Pump,
\nManjalpur \nVadodara - 390019");
getch();
}
Question:- 2 Write a C program to display the equation of a line in the form ax + by = c
where a = 5, b = 8 and c = 18.
#include <stdio.h>
#include <conio.h>
int main ()
{
clrscr();
int a = 5;
int b = 8;
int c = 18;
printf("Equation of the line is %dx + %dy = %d", a, b, c);
getch();
}
Question:- 3 Distance between two points (x1 , y1) and (x2 , y2) is governed by the formula
D2 = (x2 – x1)2 + (y2 –
y1)2
Write a C program to compute D given, the coordinates of the point.
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()
{
clrscr();
float x1, x2, y1, y2;
float D;
printf("Enter the coordinates of x1:- ");
scanf("%f", &x1);
printf("Enter the coordinates of x2:- ");
scanf("%f", &x2);
printf("Enter the coordinates of y1:- ");
scanf("%f", &y1);
printf("Enter the coordinates of y2:- ");
scanf("%f", &y2);
D = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
printf(" D is %f", sqrt(D));
getch();
}
Question:- 4 Write a C program to read the prize of an item in decimal form (like 16.34) and print the output in pasia.
#include <stdio.h>
#include <conio.h>
int main ()
{
clrscr();
float prize;
printf("Enter the value your item:- ");
scanf("%f", &prize);
float prize_paisa = prize*100;
printf("Prize of your item in paisa is %.2f", prize_paisa);
getch();
return 0;
}
Question:- 5 Write a C program to read two floating points no. using a scanf statement, assign thier sum to a integer variable and then output, the values of all three variables.
#include <stdio.h>
#include <conio.h>
int main ()
{
float a,b;
float c;
printf("Enter 1st floating value :");
scanf("%f",&a);
printf("\n Enter 2nd floating value ");
scanf("%f",&b);
c = a+b;
printf(" your 1st floating value was %.3f and 2nd was %.3f\n and
now their output is %.3f",a,b,c);
getch();
}