- To display "Hello World"
#include <stdio.h>
#include <conio.h>
int main( )
{
printf ("Hello world \n");
return ( 0 ) ;
}
#include<stdio.h>
int main( )
{
int a, b, c;
printf("Enter two numbers to add \n");
scanf("%d%d",&a,&b);
c = a + b;
printf("Sum of entered numbers = %d\n",c);
return (0);
}
- To decide whether a number is odd or even
#include <stdio.h>
int main( )
{
int n;
printf ("Enter an integer \n");
scanf ("%d", &n);
if (n%2 == 0)
printf("Even\n");
else
printf("Odd\n");
return (0);
}
No comments:
Post a Comment