0% found this document useful (0 votes)
6 views2 pages

C Programs for Sum, Positivity, Odd/Even

The document contains two C programs. The first program calculates the sum of two integers input by the user and prints the result, while the second program checks if a number is positive, negative, or zero. Additionally, a third program checks if a number is odd or even and prints the corresponding output.

Uploaded by

anitha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

C Programs for Sum, Positivity, Odd/Even

The document contains two C programs. The first program calculates the sum of two integers input by the user and prints the result, while the second program checks if a number is positive, negative, or zero. Additionally, a third program checks if a number is odd or even and prints the corresponding output.

Uploaded by

anitha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Program:1

#include <stdio.h>

i n t m a i n ( )

i n t a , b , c ;

c l r s c r ( ) ;

s c a n f ( “ % d % d ” , & a , & b ) ;

c = a + b ;

p r i n t f ( “ T h e s u m i s % d ” , c ) ;

g e t c h ( ) ;

r e t u r n 0 ;

P r o g r a m : 2

#include <stdio.h>

void main()
{
int N = 10;

if (N == 0)
{
printf("Zero\n");
}

else if (N < 0)
{
printf("Negative\n");
}
// If neither, the number is positive
else
{
printf("Positive\n");
}
return 0;
}
Output:Positive

Program:2

#include <stdio.h>

int main()
{
int N = 11;

void checkOddEven(int N)
{

// Find the remainder


int r = N % 2;

// Condition for even


if (r == 0)
{
printf("Even");
}

// Condition for odd number


else {
printf("Odd");
}
}

checkOddEven(N);
return 0;
}
Output
odd

You might also like