Basic Programmes in C
1. Hello World in C
#include<stdio.h>
int main ()
{
printf("Hello World");
return 0;
}
2.Printing string in c
#include<stdio.h>
int main()
{
printf("hello there ");
printf("we can print any data using printf ");
return 0;
}
3.Taking Input of different data types in C
#include<stdio.h>
int main ()
{
int a; /*integer data type */
float b; /* floating (decimal) point data type */
char c; /* charachter data type */
char d[50]; /* String data type */
printf("Enter Integer Value:");
scanf("%d",&a);
printf("Enter Floating Value:");
scanf("%f",&b);
printf("Enter Charachter Value:");
scanf("%c",&c);
printf("Enter String Value:");
scanf("%s",&d);
printf("Integer: %d \n Floating: %f ",a,b);
printf("Char :%c\nString :%s",c,d);
return 0;
}
For any query comment below.
0 Comments