Q:

C Program To Print Odd Numbers Between 1 To 100

belongs to collection: Basic C Programming Examples

0

you have to make this program in the following way:

  • C Program To Print Odd Numbers Between 1 To 100
  • C Program To Print Odd Numbers Between 1 To N
  • C Program To Print Odd Numbers Between 1 To 100 Using Function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program To Print Odd Numbers Between 1 To 100

Algorithm

  • Program Start
  • Declare Variable
  • check condition
  • print result according to condition
  • Program End

Program

//C Program To Print Odd Numbers Between 1 To 100 Using For Loop

#include<stdio.h>

void main()
{
    int i;

    for(i=1;i<=100;i++)
    {
        if(i%2!=0)
        {
            printf("%d \n",i);
        }
    }
}

Output

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

C Program To Print Odd Numbers Between 1 To N\

Program

//C Program To Print Odd Numbers Between 1 To N

#include<stdio.h>

void main()
{
    int i,n;
    printf("Enter how many number you want \n");
    scanf("%d",&n);

    printf("Odd Numbers Between 1 to %d : \n",n);
    for(i=1;i<=n;i++)
    {
        if(i%2!=0)
        {
            printf("%d \n",i);
        }
    }
}

Output

Enter how many number you want
10
Odd Numbers Between 1 to 10 :
1
3
5
7
9

C Program To Print Odd Numbers Between 1 To 100 Using Function

Algorithm

  • Program Start
  • Declare Variable
  • Calling Function
  • check condition
  • print result according to condition
  • Program End

 

Program

//<span style="font-size: inherit;">C Program To Print Odd Numbers Between 1 To 100 Using Function</span> 

#include<stdio.h>

int main()
{
    //Calling Funcrion
    oddnumbers();
    return 0;
}
void oddnumbers()
{   int i;
    printf("Odd Numbers Between 1 to 100 : \n");
    for(i=1;i<=100;i++)
    {
        if(i%2!=0)
        {
            printf("%d \n",i);
        }
    }
}

Output

Odd Numbers Between 1 to 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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to Calculate Simple interest and Compoun... >>
<< C Program to Calculate Power of a Number...