Program to Display "Hello, World!"
#include <stdio.h>
#include <conio.h>
void main()
{
// printf() displays the string inside quotation
printf("tutorialsforcprogramming.blogspot.com");
getch();
}
Output
tutorialsforcprogramming.blogspot.com
Get differnet value from user & print it on diaplay
#include <stdio.h>
#include <conio.h>
void main()
{
int in;
float fn;
char c;
printf("Enter an integer: ");
scanf("%d", &in); // %d is used for get or print integer
printf("You entered: %d", in);
printf("Enter an float: ");
scanf("%f", &fn); // %f is used for get or print float
printf("You entered: %f", fn);
printf("Enter an character: "); // %c is used for get or print character
scanf("%c", &c);
printf("You entered: %c", c);
getch();
}
Output
Enter an integer: 5
You entered: 5
Enter an float: 5.005
You entered: 5.005
Enter an character: D
You entered: D
Perform some operation on integer
#include <stdio.h>
#include <conio.h>
void main()
{
int a=5;b=10,c;
c = b + a;
printf("b + a = %d", c);
c = b - a;
printf("b - a = %d", c);
c = b * a;
printf("b * a = %d", c);
c = b / a;
printf("b / a = %d", c);
}
Output
b + a = 15
b - a = 5
b * a = 50
b / a = 2