Computer Edu - CLTI
02/08/2022
C program to print the sum of all odd numbers from 1 to your input number
int main()
{
int i, n, sum=0;
/* Input Number to find sum of odd numbers */
printf("Enter a number to add range all odd number: ");
scanf("%d", &n);
for(i=1; i
CLTI | Computer Institute in Bhadohi Are you intersted in learn computer, CLTI is a one of the best place learn computer in Bhadohi, Computer intitute where you change your future
Check Max Number ino your given two number
int main()
{
int n1, n2;
printf("Please enter two numbers: ");
scanf("%d%d", &n1, &n2);
if(n1 > n2)
{
printf("Maximum is %d", n1);
}
else
{
printf("Maximum is %d", n2);
}
return 0;
}
www.clti.in
Check number is positive/negative
int main()
{
int number;
printf("Enter any number: ");
scanf("%d", &number);
if(number > 0)
{
printf("Number is POSITIVE");
}
if(number < 0)
{
printf("Number is NEGATIVE");
}
if(number == 0)
{
printf("Number is ZERO");
}
return 0;
}
Check Odd/Even Program in C language
int main()
{
int n;
printf("Enter any number to check even / odd: ");
scanf("%d", &n);
if(n % 2 == 0)
{
/* number % 2 is 0 */
printf("Number is Even.");
}
else
{
/* number % 2 is 1 */
printf("Number is Odd.");
}
return 0;
}
www.clti.in
Use if in C language
Check greater number between two number ----
int main()
{
int number_one, number_two;
printf("Enter two numbers: ");
scanf("%d%d", &number_one, &number_two);
/* Check num1 is maximum */
if(number_one > number_two)
{
printf("%d is maximum", number_one);
}
/* Check num2 is maximum */
if(number_two > number_one)
{
printf("%d is maximum", number_two);
}
/* If Number is Equal */
if(number_one == number_two)
{
printf("Both are equal");
}
return 0;
}
www.clti.in
Click here to claim your Sponsored Listing.
Category
Contact the school
Website
Address
Alampur
Bhadohi
221401