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

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 ("...