Using Comments and Identifiers

You might also like

You are on page 1of 4

1.

Hello world program


#include <stdio.h>
int main() {
// printf() displays the string inside
quotation
printf("Hello, World!");
return 0;
}

Hello, World!

2. Using comments and identifiers


#include <stdio.h>
int main()
{
int num=100;
int Num=150;
char ch = 'K';
double bigNumberWithDecimalPoints =
122343434.83823;
printf("Value of num is: %d",num);
printf("\nValue of Num is:%d",Num);
printf("\nValue of ch is: %c",ch);
printf("\nValue of double is:
%lf",bigNumberWithDecimalPoints);
return 0;
}

Output: As you can see both the “num” and “Num” identifiers
represent different variables with different values so we can say
that the identifiers are case sensitive.

3. Using array Input \output


// Program to take 5 values from the user and
store them in an array
// Print the elements stored in the array

#include <stdio.h>

int main() {

int values[5];

printf("Enter 5 integers: ");

// taking input and storing it in an array


for(int i = 0; i < 5; ++i) {
scanf("%d", &values[i]);
}

printf("Displaying integers: ");

// printing elements of an array


for(int i = 0; i < 5; ++i) {
printf("%d\n", values[i]);
}
return 0;
}
Run Code

Output
Enter 5 integers: 1
-3
34
0
3
Displaying integers: 1
-3
34
0
3

You might also like