Some simple program in C-
1.
1.
#include <stdio.h> main() { printf("Hello World\n"); return 0; }
Output:
"Hello World"
2.
#include <stdio.h> main() { int number; printf("Enter an integer\n"); scanf("%d",&number); printf("Integer entered by you is %d\n", number); return 0; }
Output:
Enter a number5 Number entered by you is 5
3.
#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;
}
4.
#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;
}
Output:
Enter two numbres to add
4
5
Sum of entered numbers=9
No comments:
Post a Comment