## Write a C C++ program to find HCF and LCM of two numbers

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C Language में Token क्या होता है जानने के लिए देखें—Data types in C

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

### C program to find HCF and LCM of two numbers

``````#include<stdio.h>
int main()
{
int a,b,i=1,hcf,lcm;
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
while(i<=a&&i<=b)
{
if(a%i==0&&b%i==0)
{
hcf=i;
}
i++;
}
lcm=(a*b)/hcf;
printf("HCF = %d\n",hcf);
printf("LCM = %d\n",lcm);
return 0;
}``````

### C++ program to find HCF and LCM of two numbers

``````#include<iostream>
using namespace std;
int main()
{
int a,b,i=1,hcf,lcm;
cout<<"Enter two numbers: ";
cin>>a>>b;
while(i<=a&&i<=b)
{
if(a%i==0&&b%i==0)
{
hcf=i;
}
i++;
}
lcm=(a*b)/hcf;
cout<<"HCF = "<<hcf<<"\n";
cout<<"LCM = "<<lcm<<"\n";
return 0;
}``````

### Output C C++ program to find HCF and LCM of two numbers

```Enter two numbers: 40 60
HCF = 20
LCM = 120```
```Enter two numbers: 16 24
HCF = 8
LCM = 48 ```
```Enter two numbers: 90 60
HCF = 30
LCM = 180 ```

Share it to:

## Write a C C++ program to generate multiplication table

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

C Language में Token क्या होता है जानने के लिए देखें—Data types in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

### C program to generate multiplication table

``````#include<stdio.h>
int main()
{
int num,c=1,res;
printf("Enter a number: ");
scanf("%d",&num);
while(c<=10)
{
res=num*c;
printf("%d*%d=%d\n",num,c,res);
c++;
}
return 0;
}``````

### C++ program to generate multiplication table

``````#include<iostream>
using namespace std;
int main()
{
int num,c=1,res;
cout<<"Enter a number: ";
cin>>num;
while(c<=10)
{
res=num*c;
cout<<num<<"*"<<c<<"="<<res<<"\n";
c++;
}
return 0;
}``````

### Output of C C++ program to generate multiplication table

```Enter a number: 5
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
5*6=30
5*7=35
5*8=40
5*9=55
5*10=50 ```
```Enter a number: 5
12*1=12
12*2=24
12*3=36
12*4=48
12*5=60
12*6=72
12*7=84
12*8=96
12*9=108
12*10=120  ```

Share it to:

## Write a C C++ program to find power of given number

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C Language की विशेषताओं एवं शक्तियों को जानने के लिए देखें—Features and Powers of C

### C program to find power of given number

``````#include<stdio.h>
int main()
{
int num,pow,c=1,res=1;
printf("Enter number: ");
scanf("%d",&num);
printf("Enter power : ");
scanf("%d",&pow);
while(c<=pow)
{
res=res*num;
c++;
}
printf("Result = %d",res);
return 0;
}``````

### C++ program to find power of given number

``````#include<iostream>
using namespace std;
int main()
{
int num,pow,c=1,res=1;
cout<<"Enter number: ";
cin>>num;
cout<<"Enter power : ";
cin>>pow;
while(c<=pow)
{
res=res*num;
c++;
}
cout<<"Result = "<<res;
return 0;
}``````

### Output of C C++ program to find power of given number

```Enter number: 5
Enter power : 3
Result = 125```
```Enter number: 3
Enter power : 4
Result = 81 ```
```Enter number: 2
Enter power : 5
Result = 32 ```

Share it to:

## Write a C C++ program to find factorial of given number

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

### C program to find factorial of given number

``````#include<stdio.h>
int main()
{
int num,c=1,res=1;
printf("Enter a number: ");
scanf("%d",&num);
while(c<=num)
{
res=res*c;
c++;
}
printf("Factorial = %d",res);
return 0;
}``````

### C++ program to find factorial of given number

``````#include<iostream>
using namespace std;
int main()
{
int num,c=1,res=1;
cout<<"Enter a number: ";
cin>>num;
while(c<=num)
{
res=res*c;
c++;
}
cout<<"Factorial = "<<res;
return 0;
}``````

### Output of C C++ program to find factorial of given number

```Enter a number: 3
Factorial = 6```
```Enter a number: 4
Factorial = 24```
```Enter a number: 5
Factorial = 120 ```

Share it to:

## Write a C C++ program to generate table of given number

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C++ Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C++

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

### C program to generate table of given number

``````#include<stdio.h>
int main()
{
int num,c=1,res;
printf("Enter a number: ");
scanf("%d",&num);
while(c<=10)
{
res=num*c;
printf("%d\n",res);
c++;
}
return 0;
}``````

### C++ program to generate table of given number

``````#include<iostream>
using namespace std;
int main()
{
int num,c=1,res;
cout<<"Enter a number: ";
cin>>num;
while(c<=10)
{
res=num*c;
cout<<res<<"\n";
c++;
}
return 0;
}``````

### Output of C C++ program to generate table of given number

```Enter a number: 5
5
10
15
20
25
30
35
40
45
50```
```Enter a number: 12
12
25
36
48
60
72
84
96
108
120```

Share it to:

## C C++ program to generate series of even numbers and find sum

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

### C program to generate series of even numbers and find sum

``````#include<stdio.h>
int main()
{
int num=2,n,sum=0;
printf("Enter n: ");
scanf("%d",&n);
while(num<=n)
{
printf("%d\n",num);
sum=sum+num;
num=num+2;
}
printf("Sum of series = %d",sum);
return 0;
}``````

### C++ program to generate series of even numbers and find sum

``````#include<iostream>
using namespace std;
int main()
{
int num=2,n,sum=0;
cout<<"Enter n: ";
cin>>n;
while(num<=n)
{
cout<<num<<"\n";
sum=sum+num;
num=num+2;
}
cout<<"Sum of series = "<<sum;
return 0;
}``````

### Output of C C++ program to generate series of even numbers and find sum

```Enter n: 10
2
4
6
8
10
Sum of series: 30```
```Enter n: 10
2
4
6
8
10
12
14
16
18
20
Sum of series: 110```

Share it to:

## C C++ program to generate series of odd numbers and find sum

### Flowchart to generate series of odd numbers and find sum

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

### C program to generate series of odd numbers and find sum

``````#include<stdio.h>
int main()
{
int num=1,n,sum=0;
printf("Enter n: ");
scanf("%d",&n);
while(num<=n)
{
printf("%d\n",num);
sum=sum+num;
num=num+2;
}
printf("Sum of series = %d",sum);
return 0;
}``````

### C++ program to generate series of odd numbers and find sum

``````#include<iostream>
using namespace std;
int main()
{
int num=1,n,sum=0;
cout<<"Enter n: ";
cin>>n;
while(num<=n)
{
cout<<num<<"\n";
sum=sum+num;
num=num+2;
}
cout<<"Sum of series = "<<sum;
return 0;
}``````

### Output of C C++ program to generate series of odd numbers and find sum

```Enter n: 10
1
3
5
7
9
Sum of series = 25```
```Enter n: 20
1
3
5
7
9
11
13
15
17
19
Sum of series = 100```

Share it to:

## C C++ program to generate series of natural numbers and find sum

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

### C program to generate series of natural numbers and find sum

``````#include<stdio.h>
int main()
{
int num=1,n,sum=0;
printf("Enter n: ");
scanf("%d",&n);
while(num<=n)
{
printf("%d\n",num);
sum=sum+num;
num++;
}
printf("Sum of series = %d",sum);
return 0;
}``````

### C++ program to generate series of natural numbers and find sum

``````#include<iostream>
using namespace std;
int main()
{
int num=1,n,sum=0;
cout<<"Enter n: ";
cin>>n;
while(num<=n)
{
cout<<num<<"\n";
sum=sum+num;
num++;
}
cout<<"Sum of series = "<<sum;
return 0;
}``````

### Output of C C++ program to generate series of natural numbers and find sum

```Enter n: 5
1
2
3
4
5
Sum of series = 15```
```Enter n: 10
1
2
3
4
5
6
7
8
9
10
Sum of series = 55 ```

Share it to:

## Write a C C++ program to generate series of natural numbers

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

### C program to generate series of natural numbers using while loop

``````#include<stdio.h>
int main()
{
int num=1;
while(num<=5)
{
printf("%d\n",num);
num++;
}
return 0;
}``````

### C program to generate series of natural numbers using for loop

``````#include<stdio.h>
int main()
{
int num;
for(num=1; num<=5; num++)
{
printf("%d\n",num);
}
return 0;
}``````

### C program to generate series of natural numbers using do while loop

``````#include<stdio.h>
int main()
{
int num=1;
do
{
printf("%d\n",num);
num++;
}while(num<=5);
return 0;
}``````

### C++ program to generate series of natural numbers using while loop

``````#include<iostream>
using namespace std;
int main()
{
int num=1;
while(num<=5)
{
cout<<num<<"\n";
num++;
}
return 0;
}``````

### C++ program to generate series of natural numbers using for loop

``````#include<iostream>
using namespace std;
int main()
{
int num;
for(num=1; num<=5; num++)
{
cout<<num<<"\n";
}
return 0;
}``````

### C++ program to generate series of natural numbers using do while loop

``````#include<iostream>
using namespace std;
int main()
{
int num=1;
do
{
cout<<num<<"\n";
num++;
}while(num<=5);
return 0;
}``````

```1
2
3
4
5```

Share it to: