Advertisement
madhawaseeeee

c practicle codes

Jan 3rd, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.87 KB | None | 0 0
  1. // first_c.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #
  5. include "stdio.h"
  6.  
  7. int main() {
  8.  
  9.   star_6();
  10.  
  11.   return 0;
  12. }
  13.  
  14. cube() {
  15.  
  16.   int marks;
  17.  
  18.   printf("please enter your mark here!\n");
  19.   scanf_s("%d", & marks);
  20.  
  21.   if (marks > 40) {
  22.  
  23.     printf("your mark is good!");
  24.  
  25.   } else {
  26.  
  27.     printf("your mark is not good!");
  28.  
  29.   }
  30.  
  31. }
  32.  
  33. square() {
  34.  
  35.   float num;
  36.  
  37.   printf("please enter your number here!\n");
  38.   scanf_s("%f", & num);
  39.  
  40.   float square = num * num;
  41.   float cube = num * num * num;
  42.  
  43.   printf("square of the number is : %f\n", square);
  44.   printf("cube of the number is : %f\n", cube);
  45.  
  46. }
  47.  
  48. celsius() {
  49.  
  50.   float fahrenheit;
  51.  
  52.   printf("please enter fahrenheit here!\n");
  53.   scanf_s("%f", & fahrenheit);
  54.  
  55.   float C = 5 / 9.0 * (fahrenheit - 32);
  56.  
  57.   printf("celsius of the fahrenheit is : %f\n", C);
  58.  
  59. }
  60.  
  61. area() {
  62.  
  63.   float length;
  64.  
  65.   printf("please enter the length of the sqaure : \n");
  66.   scanf_s("%f", & length);
  67.  
  68.   float area = length * length;
  69.  
  70.   printf("area of the square is : %f\n", area);
  71.  
  72. }
  73.  
  74. tax() {
  75.  
  76.   float amount;
  77.   float tax_rate;
  78.  
  79.   printf("please enter the amount of the good here : \n");
  80.   scanf_s("%f", & amount);
  81.   printf("please enter the tax rate of the good here : \n");
  82.   scanf_s("%f", & tax_rate);
  83.  
  84.   float sales_tax = amount * tax_rate / 100;
  85.  
  86.   printf("sales tax of the good is : %f\n", sales_tax);
  87.  
  88.   float total_amount = amount + sales_tax;
  89.  
  90.   printf("total amount of the good id : %f\n", total_amount);
  91.  
  92. }
  93.  
  94. price() {
  95.  
  96.   float price_of_item;
  97.   float amount_of_cash;
  98.  
  99.   printf("please enter price of the item here!\n");
  100.   scanf_s("%f", & price_of_item);
  101.   printf("please enter the amount of the cash , the customer gave you here\n");
  102.   scanf_s("%f", & amount_of_cash);
  103.  
  104.   float amount_of_change = amount_of_cash - price_of_item;
  105.  
  106.   printf("amount of change that given to customer is : %f\n", amount_of_change);
  107.  
  108. }
  109.  
  110. star_1() {
  111.  
  112.   for (int i = 0; i < 4; i++) {
  113.  
  114.     //printf("\n");
  115.  
  116.     for (int j = 0; j < 5; j++) {
  117.  
  118.       printf("*");
  119.  
  120.     }
  121.  
  122.     printf("\n");
  123.  
  124.   }
  125.  
  126. }
  127.  
  128. star_2() {
  129.  
  130.   for (int i = 1; i < 5; i++) {
  131.  
  132.     for (int j = 0; j < i; j++) {
  133.  
  134.       printf("*");
  135.  
  136.     }
  137.  
  138.     printf("\n");
  139.  
  140.   }
  141.  
  142. }
  143.  
  144. star_3() {
  145.  
  146.   for (int i = 1; i < 5; i++) {
  147.  
  148.     for (int j = 0; j < i; j++) {
  149.  
  150.       printf("%d", i);
  151.  
  152.     }
  153.  
  154.     printf("\n");
  155.  
  156.   }
  157.  
  158. }
  159.  
  160. star_4() {
  161.  
  162.   for (int i = 1; i < 5; i++) {
  163.  
  164.     int a = 65;
  165.  
  166.     for (int j = 0; j < i; j++) {
  167.  
  168.       printf("%c", a + j);
  169.  
  170.     }
  171.  
  172.     printf("\n");
  173.   }
  174.  
  175. }
  176.  
  177. star_5() {
  178.  
  179.   for (int i = 5; i > 0; i--) {
  180.  
  181.     for (int j = 0; j < i; j++) {
  182.  
  183.       printf("*");
  184.  
  185.     }
  186.  
  187.     printf("\n");
  188.  
  189.   }
  190.  
  191. }
  192.  
  193. star_6() {
  194.  
  195.   for (int i = 1; i < 5; i++) {
  196.  
  197.     int a = 1;
  198.  
  199.     for (int j = 0; j < i; j++) {
  200.  
  201.       printf("%d", a + j);
  202.  
  203.     }
  204.  
  205.     printf("\n");
  206.   }
  207.  
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement