Basic C Programs
Basic C Programs
Program:
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
Output:
Hello, world!
Program:
#include <stdio.h>
int main() {
return 0;
Output:
Program:
// C program to demonstrate syntax of binary arithmetic
// operators
#include <stdio.h>
int main()
{
int a = 10, b = 4, res;
// printing a and b
printf("a is %d and b is %d\n", a, b);
res = a + b; // addition
printf("a + b is %d\n", res);
res = a - b; // subtraction
printf("a - b is %d\n", res);
res = a * b; // multiplication
printf("a * b is %d\n", res);
res = a / b; // division
printf("a / b is %d\n", res);
res = a % b; // modulus
printf("a %% b is %d\n", res);
return 0;
}
Output:
a is 10 and b is 4
a + b is 14
a - b is 6
a * b is 40
a / b is 2
a % b is 2
4. Write a C program on any one Conditional statement.
Program:
Output:
Good evening.
Program:
#include<stdio.h>
int main(){
int i=0;
for(i=1;i<=10;i++){
printf("%d \n",i);
return 0;
Output:
1
2
3
4
5
6
7
8
9
10
---THE END---