0% found this document useful (0 votes)
14 views5 pages

Ip Unit 1 Short

Konderripookulu raa meeru

Uploaded by

nosido8203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

Ip Unit 1 Short

Konderripookulu raa meeru

Uploaded by

nosido8203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

UNIT 1

1. Define program? Write a C program for 'Hello world'.

A program is a sequence of instructions written in a programming language to perform a specific task on a


computer.
C Program:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

Output:
Hello, World!

2. What is a compiler?

A compiler is a software that translates code written in a high-level programming language into machine language
(binary code) that a computer's processor can understand and execute.

3.Define flowchart? What are the different symbols in flowchart?

A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a
diagrammatic representation of an algorithm, a step-by-step approach to solving a task.
4. What are the different rules to create a variable?

 Rules to create a variable:


- A variable name must start with a letter or an underscore character (_)
 A variable name cannot start with a digit
 A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three different variables)
 There is no limit on the length of the variable name
 A variable name cannot contain spaces
 The variable name cannot be any Go keywords

Example:-

#include<stdio.h>

void main(){

int number;

scanf(“%d”,&number);

printf(“%d”,number);

} // number is variable.

5. What are different levels of programming languages?

Programming languages can be classified into three categories as follows :

1.Low-level programming languages: Here, communication with system is in binary format , i.e, in , 0's and 1's,
which can be directly executed. This means that these languages provide instructions which can be used to
perform low-level operations like memory management etc. For example: Assembly Languages.

2.High-level programming languages: Here,communication with system is in the form of text (usually in English)
which can easily be read/understood by humans. For example: Ada, JavaScript, Python, Ruby etc.

3.Middle-level programming languages: These are languages that support both the features of low-level and
high-level programming languages . These are also written in text which can easily be read by humans . They
typically use tools like compilers to convert the instructions that are readable by humans (high-level language
constructs) into low-level executable code (usually in binary format). Eg: C, C++, Java, etc,.

6. Distinguish between compilation and execution?


Compilation:
The process of converting source code into machine code that can be executed by a computer. A compiler
checks the source code for syntax errors and creates an object file if the code is error-free..
Execution
The process of running the compiled code on a physical device, such as a CPU. Execution happens at runtime.
7. What is time complexity?

Time complexity refers to the amount of time an algorithm takes to run as a function of the size of the input data.

Performance:

Best Case: The scenario where the algorithm performs the fastest.

Worst Case: The scenario where the algorithm takes the longest to complete.

Average Case: The expected time for a typical input.

8. What is space complexity?

Space complexity refers to the amount of memory an algorithm uses as a function of the size of the input. It
measures the total space required by the algorithm, including both the space for input data and any auxiliary
space needed during the algorithm's execution.

Key Points:
Input Space: The space required to store the input data. This is typically proportional to the size of the input
(n).
Auxiliary Space: The extra space or temporary storage used by the algorithm apart from the input data, such
as variables, arrays, stacks, or recursion stacks
Total Space Complexity = Input Space + Auxiliary Space
9. List the data types and their sizes of C language.

C Code to Print the Sizes of Data Types:

#include <stdio.h>

int main() {
printf("Size of char: %lu byte\n", sizeof(char));
printf("Size of int: %lu bytes\n", sizeof(int));
printf("Size of short: %lu bytes\n", sizeof(short));
printf("Size of long: %lu bytes\n", sizeof(long));
printf("Size of long long: %lu bytes\n", sizeof(long long));
printf("Size of float: %lu bytes\n", sizeof(float));
printf("Size of double: %lu bytes\n", sizeof(double));

return 0;
}

OUTPUT:
Size of char: 1 byte
Size of int: 4 bytes
Size of short: 2 bytes
Size of long: 8 bytes
Size of long long: 8 bytes
Size of float: 4 bytes
Size of double: 8 bytes

10. Define precedence and order of evaluation.

Precedence refers to the priority of operators in expressions. Order of evaluation is the sequence in which the
operations are performed in an expression according to operator precedence.

You might also like