Example-1: C program to print Hello World
{
int a;
printf("Enter the No \n");
scanf("%d",&a);
printf("Integer of %d=%d",a);
getch ( );
return 0;
}
Example-3: C program to print either a no. is equal to or not equal to using if else control instructions
{
}
Example-4: C Program to check Whether a number enter by user is even or odd
int main( )
{
int a;
printf("Enter a number");
scanf("%d",&a);
if((a%2)==0)
printf("%d is even.",a);
else
printf("%d is odd.",a);
getch( );
return 0;
}
OR
#include <stdio.h>
#include <conio.h>
int main( )
{
printf("Hello World\n");
getch ( );
return 0;
}
Example-2: C program to take input from user using scanf
#include <stdio.h>
#include <conio.h>
int main( ){
int a;
printf("Enter the No \n");
scanf("%d",&a);
printf("Integer of %d=%d",a);
getch ( );
return 0;
}
Example-3: C program to print either a no. is equal to or not equal to using if else control instructions
#include <stdio.h>
#include <conio.h>
int main( ){
int x;
printf("Enter the value of x");
scanf("%d",&x);
if(x==5)
printf("x is equal to 5.\n");
else
printf("x is not equal to 5. \n");
getch ( );
return 0;
printf("Enter the value of x");
scanf("%d",&x);
if(x==5)
printf("x is equal to 5.\n");
else
printf("x is not equal to 5. \n");
getch ( );
return 0;
}
Example-4: C Program to check Whether a number enter by user is even or odd
#include <stdio.h>
#include <conio.h>
{
int a;
printf("Enter a number");
scanf("%d",&a);
if((a%2)==0)
printf("%d is even.",a);
else
printf("%d is odd.",a);
getch( );
return 0;
}
OR
/*c Program to check whether a number enter by user is even or odd. */
#include <stdio.h>
#include <conio.h>
int main( )
{
int a;
printf("Enter a number");
scanf("%d",&a);
((a%2)==0)? printf("%d is even.",a):printf("%d is odd.",a);
getch( );
return 0;
No comments:
Post a Comment