PROBLEM SOLVING USING C LAB Programs -JNTUK(R20)-2021-22

 

PROBLEM SOLVING USING C LAB Programs -JNTUK(R20)




Excercise -1
Write a C program to print a block F using hash (#), where the F has a height of six characters and width of five and four characters.

/* Write a C program to print a block F using hash (#), where the F has a height of six characters and width of five and four characters. */

#include<stdio.h>
int main( )
{
    printf("######\n");
    printf("#\n");
    printf("#\n");
    printf("#####\n");
    printf("#\n");
    printf("#\n");
    printf("#");
    return 0;
}

Output:

Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches.

/*Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches. */
 
#include <stdio.h>
int main( )
{
    int a,p;
    a=7*5;
    p=2*(7+5);
    printf("Area of the rectangle is %d\n",a);
    printf("Perimeter of a rectangle = %d\n",p);
    return 0;
}

Output:

Area of the rectangle is 35
Perimeter of a rectangle is 24

Write a C program to display multiple variables.

/* Write a C program to display multiple variables. */

 #include<stdio.h>

int main( )

{

    char c='V';

    int i=678;

    float f=12.23;

    double d=12.123456789;

    printf("Character = %c\n",c);

    printf("Integer = %d\n",i);

    printf("Float = %f\n",f);

    printf("Double = %lf\n",d);

    return 0;

}


Output:

Character = V

Integer = 678

Float = 12.230000

Double = 12.123457


Excercise -2
Write a C program to calculate the distance between the two points.

 /* Write a C program to calculate the distance between the two points. */


#include<stdio.h>
#include<math.h>
int main( )
{
    int x1,x2,y1,y2;
    int x,y;
    float d;
    printf("Enter the coordinates of first point(x1,y1):");
    scanf("%d%d",&x1,&y1);
    printf("Enter the coordinates of the second point(x2,y2):");
    scanf("%d%d",&x2,&y2);
    x = (x2-x1);
    y = (y2-y1);
    d = sqrt((x*x)+(y*y));
    printf("Distance = %.2f\n",d);
    return 0;
}
  
Output:

Enter the coordinates of first point(x1,y1):3 7
Enter the coordinates of the second point(x2,y2):5 8
Distance = 2.236
Write a C program that accepts 4 integers p, q, r, s from the user where r and s are positive and p is even. If q is greater than r and s is greater than p and if the sum of r and s is greater than the sum of p and q print "Correct values", otherwise print "Wrong values".

Complete Lab Manual Download Below 



1 comment

  1. Classic Titanium Shaving Razors with Classic Blades - TITNIA
    Classic titanium flash mica Titanium Shaving Razors with Classic Blades - TITNIA. titanium nitride gun coating One of the most reliable revlon hair dryer brush titanium of quality products. titanium eyeglass frames Includes one of the titanium coating most unique

    ReplyDelete

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...