Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Date: 13/01/2021

Roll No. and Name: 20TIC027 Om Gupta


Course Code and Name: 2CS101 Computer Programming
Practical No: 1(a)
Aim: Introduction to CodeBlocks IDE. Use CodeBlocks to write and compile a
simple C program (“Hello World”).
Methodology Followed:
#include<stdio.h>
void main()
{
printf("Hello World!!");
}
Theoretical Principles Used:
In this program we have used printf() method to print the required output. This
method is a part of inbuilt library as is defined in stdio.h.
Input/Output:

Practical No: 1(b) i)


Aim: To scan and print values of different types of variables
Methodology Followed:
#include <stdio.h>
int main()
{
char c = 'A';
char str[20] = "helloeveryone";
float f = 10.234;
int n = 150;
double dbl = 20.123456;
printf("Character is %c \n", c);
printf("String is %s \n" , str);
printf("Float value is %f \n", f);
printf("Integer value is %d\n" , n);
printf("Double value is %lf \n", dbl);
printf("Octal value is %o \n", n);
printf("Hexadecimal value is %x \n", n);
return 0;
}
Theoretical Principles Used:
In this program we have used different type of data types and we have printed them
using printf() function
Input/Output:

Practical No.: 1 (b) ii)


Aim: To print address of a variable
Methodology Followed:
#include <stdio.h>
int main(void)
{
int first;
float second;
char third;
printf("Address of first variable: %p\n", &first);
printf("Address of second variable: %p\n", &second);
printf("Address of third variable: %p\n", &third);
return 0;
}
Theoretical Principles Used:
In this program we have printed address of different variables of different data-
types with “address-of (&)” variable. In C, this is a variable used in printf() to print
the memory address of the variable. The memory address varies in each system.
Input/Output:

Practical No.: 1 (b) iii)


Aim: To demonstrate different escape sequences
Methodology Followed:
#include<stdio.h>
int main()
{
printf("Hey \t there. \nThis program is to demonstrate \\ different escape
sequences in C \'as per\' \"Practical1\" part B \part\b 2.");
}
Theoretical Principles Used:
In this program we have used different types of escape sequences. Escape
sequences are a sequence of characters that does not represent itself when used
inside a character or string literal, but is translated into another character or a
sequence of characters that may be difficult or impossible to represent directly.
Input/Output:

Conclusion:
Hereby, we have learnt how to use CodeBlocks, printf(), various data-types and
address-of variable along with different escape sequences.

References:
https://www.google.com/search?q=escape+sequence+in+c&oq=escape+se&aqs=c
hrome.2.0i433i457j0l2j69i57j0j69i60l3.4034j1j9&sourceid=chrome&ie=UTF-8

You might also like