Wednesday, May 17, 2023

print a multiplication table of any integer taking from user

 //print a multiplication table of any integer taking from user 

#include "stdio.h"

int main ()

{

int n,mul,i;

printf ("Enter any number :\n");

scanf ("%d",&n);

printf ("the multiplication table of %d is:\n ",n);

for(i=1;i<=10;i++){

mul=n*i;

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

}

return 0;

}

    output             output                output                output       

Enter any number :

9

the multiplication table of 9 is:

 9*1=9

9*2=18

9*3=27

9*4=36

9*5=45

9*6=54

9*7=63

9*8=72

9*9=81

9*10=90

Sunday, May 14, 2023

Write a C program to find sum of all odd numbers between 1 to n using while loop

//Write a C program to find sum of all odd numbers between 1 to n.

#include "stdio.h"

int main (){

int num,i,sum;

printf ("Enter the value of number :\n");

scanf ("%i",&num);


i=1;

while(i<=num){

sum=sum+i;

i=i+2;

}

printf ("The sum of all odd numbers between 1 to n is %i",sum);

return 0;


}


output  output       output     output 

 Enter the value of number :

10

The sum of all odd numbers between 1 to n is 25

Write a C program to find sum of all even numbers between 1 to n using while loop

//Write a C program to find sum of all even numbers between 1 to n.

#include "stdio.h"

int main (){

int num,i,sum;

printf ("Enter the value of number :\n");

scanf ("%i",&num);


i=2;

while(i<=num){

sum=sum+i;

i=i+2;

}

printf ("The sum of all even numbers between 1 to n is %i",sum);

return 0;


}

  output                   output                       output                    output          

Enter the value of number :

10

The sum of all even numbers between 1 to n is 30

Saturday, May 13, 2023

Write a C program to print all odd number between 1 to n using while loop

 //Write a C program to print all odd number between 1 to n using while loop

#include "stdio.h"

int main ()

{

int n,i;

printf ("the value of n is :\n");

scanf ("%i",&n);

i=1;

while(i<=n)

{

printf ("%i \n",i);

i=i+2;

}

return 0;

}

   output             output            output         output 

the value of n is :

100

1

3

5

7

9

11

13

15

17

19

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

51

53

55

57

59

61

63

65

67

69

71

73

75

77

79

81

83

85

87

89

91

93

95

97

99

Write a C program to print all even numbers between 1 to 100. – using while loop

//Write a C program to print all even numbers between 1 to 100. – using while loop

#include "stdio.h"

int main (){

int i;

printf ("the series of all even numbers from 1 to 100 are:\n" );

   i=2;

while(i<=100){

printf ("%i\n",i);

i=i+2;

}

return 0;

}

output    output    output   output 

 the series of all even numbers from 1 to 100 are:

2

4

6

8

10

12

14

16

18

20

22

24

26

28

30

32

34

36

38

40

42

44

46

48

50

52

54

56

58

60

62

64

66

68

70

72

74

76

78

80

82

84

86

88

90

92

94

96

98

100

Write a C program to print all alphabets from a to z. – using while loop

 //Write a C program to print all alphabets from a to z. – using while loop

#include "stdio.h"

int main (){


char ch;

printf ("The series of all alphabets from a to z are :\n");

ch='a';

while(ch<='z'){

printf ("%c ",ch);

ch++;

}

return 0;

}

   output                    output                           output      

The series of all alphabets from a to z are :

a b c d e f g h i j k l m n o p q r s t u v w x y z                

write A programme to print all natural number from n to 1 using while loop

//write A programme to print all natural number from n to 1 using while loop 

#include "stdio.h"

int  main ()

{

int n,i;

printf ("Enter the last number:\n ");

scanf ("%i",&n);

printf ("The series is :\n");

i=n;

while(i>=1){

printf ("%i\n",i);

i--;

}

return 0;

}


output output output  output

 Enter the last number:

 10

The series is :

10

9

8

7

6

5

4

3

2

1

write A programme to print all natural number from 1 to n using while loop

 //write A programme to print all natural number from 1 to n using while loop 

#include "stdio.h"

int  main ()

{

int n,i;

printf ("Enter the last number:\n ");

scanf ("%i",&n);

i=1;

while(i<=n){

printf ("%i\n",i);

i++;

}

return 0;

}


 output               output                       output              Enter the last number:

 10

The series is :

1

2

3

4

5

6

7

8

9

10

write A programme to print the sum of all natural number from 1 to n using while loop

  //write A programme to print all natural number from 1 to n using while loop

#include "stdio.h"
int main (){
    int n,i,sum;
    printf ("Enter the last number of the series :\n");
    scanf ("%i",&n);
    i=1;
     while (i<=n){
        sum=sum+i;
        i++;
     }
     printf ("The sum of the series is %i",sum);
     return 0;
}

output :

Enter the last number of the series : 10 The sum of the series is 55

Saturday, May 6, 2023

find bmi for a human body

 // find bmi for a human body

#include "stdio.h"
int main (){
    float  h,w,b;
    printf ("Enter the height (in meter ) and weight (in kg ) for a person :\n");
    scanf ("%f%f",&h,&w);
     b=(float)w/(h*h);
    printf ("the bmi of the  man is : %f\n ",b);
    return 0;

}
output output output

Enter the height (in meter ) and weight (in kg ) for a person : 1.75 80 the bmi of the man is : 26.122450

Monday, May 1, 2023

Program to print ASCII table.

 //Program to print ASCII table.

 

#include <stdio.h>

int main()

{

    unsigned char count;

    for(count=1; count< 255; count++)

    {

        printf("  %d - %c  \n",count,count);

       

    }

    return 0;

}


                  output               output             output             1 - ☺

  2 - ☻

  3 - ♥

  4 - ♦

  5 - ♣

  6 - ♠

  7 -

  8 -

  9 -

  10 -


  11 -


  12 -


  13 -

  14 -

  15 -

  16 - ►

  17 - ◄

  18 - ↕

  19 - ‼

  20 - ¶

  21 - §

  22 - ▬

  23 - ↨

  24 - ↑

  25 - ↓

  26 - →

  27 -


8 - ∟

  29 - ↔

  30 - ▲

  31 - ▼

  32 -

  33 - !

  34 - "

  35 - #

  36 - $

  37 - %

  38 - &

  39 - '

  40 - (

  41 - )

  42 - *

  43 - +

  44 - ,

  45 - -

  46 - .

  47 - /

  48 - 0

  49 - 1

  50 - 2

  51 - 3

  52 - 4

  53 - 5

  54 - 6

  55 - 7

  56 - 8

  57 - 9

  58 - :

  59 - ;

  60 - <

  61 - =

  62 - >

  63 - ?

  64 - @

  65 - A

  66 - B

  67 - C

  68 - D

  69 - E

  70 - F

  71 - G

  72 - H

  73 - I

  74 - J

  75 - K

  76 - L

  77 - M

  78 - N

  79 - O

  80 - P

  81 - Q

  82 - R

  83 - S

  84 - T

  85 - U

  86 - V

  87 - W

  88 - X

  89 - Y

  90 - Z

  91 - [

  92 - \

  93 - ]

  94 - ^

  95 - _

  96 - `

  97 - a

  98 - b

  99 - c

  100 - d

  101 - e

  102 - f

  103 - g

  104 - h

  105 - i

  106 - j

  107 - k

  108 - l

  109 - m

  110 - n

  111 - o

  112 - p

  113 - q

  114 - r

  115 - s

  116 - t

  117 - u

  118 - v

  119 - w

  120 - x

  121 - y

  122 - z

  123 - {

  124 - |

  125 - }

  126 - ~

  127 -

  128 - Ç

  129 - ü

  130 - é

  131 - â

  132 - ä

  133 - à

  134 - å

  135 - ç

  136 - ê

  137 - ë

  138 - è

  139 - ï

  140 - î

  141 - ì

  142 - Ä

  143 - Å

  144 - É

  145 - æ

  146 - Æ

  147 - ô

  148 - ö

  149 - ò

  150 - û

  151 - ù

  152 - ÿ

  153 - Ö

  154 - Ü

  155 - ¢

  156 - £

  157 - ¥

  158 - ₧

  159 - ƒ

  160 - á

  161 - í

  162 - ó

  163 - ú

  164 - ñ

  165 - Ñ

  166 - ª

  167 - º

  168 - ¿

  169 - ⌐

  170 - ¬

  171 - ½

  172 - ¼

  173 - ¡

  174 - «

  175 - »

  176 - ░

  177 - ▒

  178 - ▓

  179 - │

  180 - ┤

  181 - ╡

  182 - ╢

  183 - ╖

  184 - ╕

  185 - ╣

  186 - ║

  187 - ╗

  188 - ╝

  189 - ╜

  190 - ╛

  191 - ┐

  192 - └

  193 - ┴

  194 - ┬

  195 - ├

  196 - ─

  197 - ┼

  198 - ╞

  199 - ╟

  200 - ╚

  201 - ╔

  202 - ╩

  203 - ╦

  204 - ╠

  205 - ═

  206 - ╬

  207 - ╧

  208 - ╨

  209 - ╤

  210 - ╥

  211 - ╙

  212 - ╘

  213 - ╒

  214 - ╓

  215 - ╫

  216 - ╪

  217 - ┘

  218 - ┌

  219 - █

  220 - ▄

  221 - ▌

  222 - ▐

  223 - ▀

  224 - α

  225 - ß

  226 - Γ

  227 - π

  228 - Σ

  229 - σ

  230 - µ

  231 - τ

  232 - Φ

  233 - Θ

  234 - Ω

  235 - δ

  236 - ∞

  237 - φ

  238 - ε

  239 - ∩

  240 - ≡

  241 - ±

  242 - ≥

  243 - ≤

  244 - ⌠

  245 - ⌡

  246 - ÷

  247 - ≈

  248 - °

  249 - ∙

  250 - ·

  251 - √

  252 - ⁿ

  253 - ²

  254 - ■


Without using power function find the cube of any given number

//Without using power function find the cube of any given number 
#include "stdio.h"
int main (){
int num,cube ;
printf ("Enter any  number:\n");
scanf ("%i",&num);
cube=num*num*num;
printf ("cube of %i is %i",num,cube);
return 0;
}

     
           output                  output              output                 output       Enter any  number:
5
cube of 5 is 125

/*Using power function find the cube of any number */

/*Using power function find the cube of any number */
#include "stdio.h"
#include "math.h"
int main ()
{
int num,cube ;
printf ("Enter the number :\n");
scanf ("%i",&num);
cube=pow(num,3);
printf ("cube of %i is %i",num,cube);
return 0;
}
        

                 output                   output                  output              output 


Enter the number :
5
cube of 5 is 125

Find the power of a number where the base and power is imputed from keyboard .

 //find the power of a number where the base and power is imputed from keyboard 

#include "stdio.h"

#include "math.h"

int main ()

{

int base,expo,result;

printf ("Enter the base and power :\n");

scanf ("%i%i",&base,&expo);

result=pow(base,expo);

printf ("%i to the  power %i is %i",base,expo,result);

return 0;

}

              output                          output                          output            

 Enter the base and power :

2

4

2 to the  power 4 is 16

Find a given triangle (with 3 sides) valid or not

 //find a given triangle (with 3 sides) valid or not 

#include "stdio.h"

int main ()

{

int s1,s2,s3;

printf ("Enter three sides :\n");

scanf ("%i%i%i",&s1,&s2,&s3);

if (s1+s2>s3 && s3>s2 && s3>s1)

{

printf ("The triangle is valid \n");

}


else if (s1+s3>s2 && s2>s3 && s2>s1)

{

printf ("The triangle is valid \n");

}

else if (s2+s3>s1 && s1>s2 && s1>s3)

{

printf ("The triangle is valid \n");

}

else if (s1==s2 && s2==s3 && s3==s1)

{

printf ("The triangle is valid \n");

}

else 

{

printf ("The triangle is not valid \n");

}

return 0;

}

                     output               output                otuput              output      

Enter three sides :

3

4

5

The triangle is valid

                                                                              or 

Enter three sides :

5

5

5

The triangle is valid

                                                    or 

Enter three sides :

5

5

4

The triangle is not valid

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...