Useful C programs.doc - Table of Contents Types Operators and Expressions.1 Control Flow.2 Functions and Program structure.3 Pointers and Arrays.5

Useful C programs.doc - Table of Contents Types Operators...

This preview shows page 1 - 4 out of 80 pages.

Table of ContentsTypes, Operators and Expressions.........................................................................................................1Control Flow..........................................................................................................................................2Functions and Program structure..........................................................................................................3Pointers and Arrays................................................................................................................................5Structures..............................................................................................................................................6Input and Output...................................................................................................................................7Types, Operators and Expressions1.Write a program to convert a given number of days into months and days. 2.Write a program to read length and width from the input and compute perimeter and area of the rectangle.
Image of page 1
area=length*width; //calculates area perimeter=2*(length+width);//calculates perimeter printf("Area is %f and perimeter is%f",area,perimeter); } Output: [[email protected] ~]$ gcc area_peri.c [[email protected] ~]$ ./a.out Enter the length and width of a reactangle:2.5 3 Area is 7.500000 and perimeter is11.000000[3.Write a program to read the diameter of the circle and compute the perimeter and area of the circle. 4.Write a program to read a floating point number from the standard input and print right most digitof the integral part and left most digit of real part.
Image of page 2
real_part=real_part*10;//gives the rightmost digit of intger part r_num=(int)real_part; printf("\n leftmost digit of realpart is %d\n right most digit of integral part is %d",r_num,i_num); return EXIT_SUCCESS; } Output: [[email protected] ~]$ gcc floatir.c [[email protected] ~]$ ./a.out Enter floating type number:1234.56 integral part is 1234 real part is 0.560059 leftmost digit of realpart is 5 right most digit of integral part is 4
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 80 pages?

  • Spring '19
  • scanf

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture