/* ****************************************
21. To Print Numbers from 5-10 using i++
****************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 5;
clrscr();
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i);
getch();
}
Output :
5
6
7
8
9
10
21. To Print Numbers from 5-10 using i++
****************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 5;
clrscr();
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i++);
printf("\n %d \n", i);
getch();
}
Output :
5
6
7
8
9
10
/* ****************************************
22. To Print Numbers from 10-5 using --i
**************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 10;
clrscr();
printf("\n %d \n", i);
printf("\n %d \n", --i);
printf("\n %d \n", --i);
printf("\n %d \n", --i);
printf("\n %d \n" ,--i);
printf("\n %d \n", --i);
getch();
}
Output :
10
9
8
7
6
5
22. To Print Numbers from 10-5 using --i
**************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 10;
clrscr();
printf("\n %d \n", i);
printf("\n %d \n", --i);
printf("\n %d \n", --i);
printf("\n %d \n", --i);
printf("\n %d \n" ,--i);
printf("\n %d \n", --i);
getch();
}
Output :
10
9
8
7
6
5
/* ***************************************
23. To Print Numbers from 5-1 using i--
************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 5;
clrscr();
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i);
getch();
}
Output :
5
4
3
2
1
23. To Print Numbers from 5-1 using i--
************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int i = 5;
clrscr();
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i--);
printf("\n %d \n", i);
getch();
}
Output :
5
4
3
2
1
/* **********************************************
24. To Find Sum of Digits of a Two Digit Number
******************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,i,j,s;
clrscr();
printf("\n Enter any Two Digit Number,To Find Sum of Digits of it : ");
scanf("%d", &n);
i = n / 10;
j = n % 10;
s = i + j;
printf("\n\n Sum of Digits of Given Number is : %d", s);
getch();
}
Output :
Enter any Two Digit Number,To Find Sum of Digits of it : 56
Sum of Digits of Given Number is : 11
24. To Find Sum of Digits of a Two Digit Number
******************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,i,j,s;
clrscr();
printf("\n Enter any Two Digit Number,To Find Sum of Digits of it : ");
scanf("%d", &n);
i = n / 10;
j = n % 10;
s = i + j;
printf("\n\n Sum of Digits of Given Number is : %d", s);
getch();
}
Output :
Enter any Two Digit Number,To Find Sum of Digits of it : 56
Sum of Digits of Given Number is : 11
/* *************************************************
25. To Check Whether Given Number is Positive or not
************************************************* */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int a;
clrscr();
printf("\n Enter any Number to Check for Positivr or not : ");
scanf("%d", &a);
if(a>0)
printf("\n\n %d is a Positive Number", a);
else
printf("\n\n %d is a Negative Number", a);
getch();
}
Output :
Enter any Number to Check for Positive or not : 46
46 is a Positive Number
25. To Check Whether Given Number is Positive or not
************************************************* */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int a;
clrscr();
printf("\n Enter any Number to Check for Positivr or not : ");
scanf("%d", &a);
if(a>0)
printf("\n\n %d is a Positive Number", a);
else
printf("\n\n %d is a Negative Number", a);
getch();
}
Output :
Enter any Number to Check for Positive or not : 46
46 is a Positive Number
0 comments:
Post a Comment